What does “You are in the middle of an am session” mean?

前端 未结 3 1171
执笔经年
执笔经年 2021-01-04 06:39

When I run git status, this is what I am seeing:

$ git status
On branch master
Your branch is ahead of \'origin/master\' by 1 commit.
  (use \"g         


        
3条回答
  •  梦毁少年i
    2021-01-04 07:35

    fix conflicts

    Do a git diff to see if you have any merge marker, like:

    $ git diff hello.txt
    diff --cc hello.txt
    index 5eb9649,379bd44..0000000
    --- a/hello.txt
    +++ b/hello.txt
    @@@ -1,1 -1,1 +1,7 @@@
    ++<<<<<<< HEAD
     +Hello, master change.
    ++||||||| merged common ancestors
    ++Hello, Original.
    ++=======
    + Hello, branch b1 change.
    ++>>>>>>> b1
    

    If not, try and reapply git am with the -3 option: git am -3

    If you have, do, for instance using kdiff3 (Windows or Linux), git mergetool --tool=kdiff3. That will launch a graphical tool allowing you to chose between local, base and remote

    +--------------------------------+
    | BASE   |    LOCAL     | REMOTE |
    +--------------------------------+
    |             MERGED             |
    +--------------------------------+
    

    http://tedfelix.com/software/git-mergetool-kdiff3.png

    With:

    • LOCAL: A temporary file containing the contents of the file on the current branch.
    • BASE: A temporary file containing the common base for the merge.
    • REMOTE: A temporary file containing the contents of the file to be merged.
    • MERGED: The file containing the conflict markers.

    The git am --continue should only be done when git status doesn't report any unstaged files.

    See more with Git Conflict Resolution by Ted Felix: it has this handy summary:

    1. Always use "-3" with "git am" to make sure you get conflict markers.
    2. Use "git status" and "git diff" to find out what went wrong.
    3. Resolve the conflicts by any of the following methods:
      • Edit each conflicting file with your favorite editor.
      • "git checkout --theirs" or "git checkout --ours".
      • "git checkout -m" to undo conflict resolution on specific files. (BE CAREFUL!)
      • "git mergetool" and an appropriate merge GUI tool like kdiff3.
    4. "git add" the resolved files.
    5. "git am --continue" to continue the am.

    With Git 2.17 (Q2 2018), don't forget to start your git am session with git am --show-current-patch to get a better view of the path to edit in case of conflict.
    See "Show current git interactive rebase operation".

提交回复
热议问题