Re: Now What?
From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:10
On Thu, 3 Nov 2005, Peter Eriksen wrote:
Here's one I've done too many times: ~/git/git-core]cat .git/remotes/origin URL: git://git.kernel.org/pub/scm/git/git.git Pull: master:origin ~/git/git-core]git-checkout maint ~/git/git-core]git pull Unpacking 222 objects 100% (222/222) done * committish: 9534f40bc42dd826cc26c8c8c84f6a8a5fc569f6 branch 'master' of git://git.kernel.org/pub/scm/git/git * refs/heads/origin: storing branch 'master' of * git://git.kernel.org/pub/scm/git/git Trying really trivial in-index merge... fatal: Merge requires file-level merging Nope. Trying simple merge. Simple merge failed, trying Automatic merge. Auto-merging Documentation/tutorial.txt. Auto-merging Makefile. merge: warning: conflicts during merge ERROR: Merge conflict in Makefile. Auto-merging apply.c. Auto-merging cache.h. merge: warning: conflicts during merge ERROR: Merge conflict in cache.h. Auto-merging clone-pack.c. Auto-merging connect.c. merge: warning: conflicts during merge ERROR: Merge conflict in connect.c. Auto-merging daemon.c. merge: warning: conflicts during merge ERROR: Merge conflict in daemon.c. Auto-merging debian/changelog. merge: warning: conflicts during merge ERROR: Merge conflict in debian/changelog. Auto-merging fetch-pack.c. merge: warning: conflicts during merge ERROR: Merge conflict in fetch-pack.c. Auto-merging git-branch.sh. Auto-merging git-checkout.sh. Auto-merging git-clone.sh. Auto-merging git-cvsimport.perl. merge: warning: conflicts during merge ERROR: Merge conflict in git-cvsimport.perl. Auto-merging git-fetch.sh. Auto-merging git-parse-remote.sh. Auto-merging git-tag.sh. Auto-merging quote.c. merge: warning: conflicts during merge ERROR: Merge conflict in quote.c. Auto-merging quote.h. merge: warning: conflicts during merge ERROR: Merge conflict in quote.h. Auto-merging refs.c. Auto-merging rev-list.c. Auto-merging send-pack.c. Auto-merging sha1_name.c. merge: warning: conflicts during merge ERROR: Merge conflict in sha1_name.c. Auto-merging upload-pack.c. merge: warning: conflicts during merge ERROR: Merge conflict in upload-pack.c. fatal: merge program failed Automatic merge failed; fix up by hand Indeed, what now?
You can do two things:
a) decide not to merge at all:
git reset --hard
and you're done. This is what you want to do when you just pulled the
wrong branch, for example.
IF you pulled the right branch, and you knew you had other changes through
other pulls or because you just had done your own development, you want to
look at:
b) Try to resolve the merge. Do a "git diff" and look what was unresolved
(by looking for those bog-standard resolve conflict markers like
"<<<<< old ===== new >>>>>".
Edit the conflicts by hand to what you want them to be, and do
git commit --all
to commit your manual merge.
Note that if you start doing (b) and you decide it's too much for you, you
can always go back to (a) in the end and ask for help from the people
involved.
Linus