I'd like to merge my branch into master
. I've committed everything on my branch switched to master. I need to do git pull
to make sure I'm up to date, however when I try to git merge mybranch
I get the error
error: merge is not possible because you have unmerged files.
git status
shows lots and lots of files that are modified, presumably from my most recent pull. Should I do a git add .
`git commit -m "something??", or what's the best way to handle this? It seems weird to do a commit for a bunch of changes that already have their own commits by their respective authors?
Don't use git pull
. It will just confuse you. Well, I think it already has!
All that git pull
does is run git fetch
(to obtain new commits from some other Git), followed by a second Git command. The usual second Git command is git merge
. It looks like you had it run those two commands. In this case, you had it run git fetch origin
followed by git merge origin/master
.
What's probably happened at this point is that the second command failed. But since you didn't know that git pull
meant git fetch && git merge
, all you saw was this weird error where it's complaining that you're already merging. And now you want to merge something else, but you can't, because you're still in the middle of the earlier failed merge.
If you had run git fetch origin
, you would have seen it work. Then you would have run git merge origin/whatever
and seen it fail and know that you must finish this merge, or abort it, or rebase, or whatever it is that you prefer to do at this point, before you can git merge
another branch.
The git pull
command is meant to be a convenience, a short-cut for doing the two Git commands, because a git fetch
is almost always going to be followed with either git merge
or git rebase
. So back when Git was first being built, they made only the user front end git pull
, which used the hidden back end git fetch
. But it turns out that it's often quite useful to split the two steps apart, so that you can (for instance) see what you have fetch
ed. They made git fetch
usable by mere humans (well, as much as any other Git command :-) ), and how git pull
is just meant to be convenient. Which it is, except when it isn't, like right now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With