简体   繁体   中英

Why my branch is ahead of origin/master after git review?

After having my changes submited to gerrit and accepted by a reviewer, git status complains that I'm ahead of origin/master.

Full story:

I've cloned my repo from ssh://luis@somewhere:10022/project.git

Because git review -s was complaining about a gerrit remote not existing, I did:

git remote add gerrit ssh://luis@somewhere:10022/project.git

Note that by now, origin and gerrit both point to the same place (I don't know if that's a problem).

I decided not to use a new branch and just work on master.

After my changes were done and staged I did:

git commit
git review

At this point git status says that I'm ahead of origin/master by 1 commit, which is odd because I thought that git review had an implicit push.

The changes were reviewed and accepted in the gerrit web-interface and have been merged into origin/master (everyone else can see them), but my local repo still says I'm ahead.

I tried pulling from origin but that triggered a merge, and now I'm 2 commits ahead.

Is this normal? Should I simply discard my extra local changes? Push them to origin?

Thanks,

Luis

Usually, I am able to resolve this by running

git pull

This happens because the index for git sometimes does not get updated, and has nothing to do with the git review .

Check accepted answer for 'Your branch is ahead of 'origin/master' by 1 commit' on explicit push

git review will not push your change to the master but submits a patch-set for review. This means that you local branch is indeed ahead of the master unless your patch-set has been merged with your branch. For details of which branch is being targeted you need to check your .gitreview file in the root of your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM