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

前端 未结 3 1170
执笔经年
执笔经年 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条回答
  •  一向
    一向 (楼主)
    2021-01-04 07:23

    Let's look at their meanings one by one...

    On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits)

    This means that you committed something locally but have not synced it with the origin.

    Local : The repository you cloned in your machine and started working on it.

    origin : The main repository from where every person can clone.

    You are in the middle of an am session. (fix conflicts and then run "git am --continue") (use "git am --skip" to skip this patch) (use "git am --abort" to restore the original branch)

    You were in middle of making a patch and you had conflicts , you have to either restore the things to the original state (using git am --abort) or resolve the conflicts by following these steps.

    1. Type git status
    2. Check the status , if you see file names saying (both modified)

    3. Open those files , Resolve the conflicts keeping what you want and discarding the what you don't.

    4. Now add the files you resolved the conflicts in by typing git add file1 file2

    5. Now its time to continue the session

    6. Type git am --continue

    In case you want to skip doing this patch type

    git am --skip
    

    You had some changes and you were in middle of making a patch out of it. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory)

    modified:   xxx
    modified:   xxx
    modified:   xxx
    

    Untracked files: (use "git add ..." to include in what will be committed)

    xxx
    

    no changes added to commit (use "git add" and/or "git commit -a")

    So here git is trying to inform you about the files which are changed since the last commit . The ones that were old files and you just changed somethings here and there inside it will be shown as the modified .

    The one you see under the untracked files are those which were unknown to git earlier because they are new files.

    Steps to resolve this step

    1.) For the untracked files

    1.1.) git add   and so on...
    

    2.) Commit the added files to the repository

    2.1)  git commit -m "Message of your choice"
    

    Note

    As you have mentioned you are working with a review system as well (gerrit). You might want to just add a new patch to an existing commmit rather than a new commit. If that is the case you need to do this

    git commit --amend
    

    3.) Now its time to push the code (if you want to)

    git push
    

    For gerrit do this

    git push review
    

提交回复
热议问题