I have a Git Repository and Gerrit review runs on top of this. I have Push/ Push Merge Commit privileges on this repo (which means I can bypass a Gerrit Review and merge code directly as if Gerrit did not exist).
As a part of routine activity, I merged
a completed topic(passed and approved in Gerrit) into my master
git merge master-b734912
Updating 08f272e..d265243
This step means my local/master HEAD
on SHA-1 08f272e
fast-forwarded to d265243
which is as expected
Fast-forward
followed by a push
to sync up my local with remote
git push gerrit:projectname master
The 'gerrit:' alias is defined in ssh config in my user profile
I pull back from remote/master to ensure everything is in sync
git pull gerrit:projectname master
on which I get
From gerrit:crs2awips * branch master -> FETCH_HEAD Already up-to-date.
However git log --graph --oneline master
shows the updated tree with the new commit as expected
* d265243 git commit message 2
* 08f272e git commit message 1
Whereas git log --graph --oneline origin/master
still shows the last commit before merge.
* 08f272e git commit message 1'
What is even more surprising is that Gerrit Review Web UI shows remote having the commit as updated.
Additionally, cloning the repository now will have a master
branch with commit-id as expected.
From the above I conclude...somehow locally HEAD
is not updated after git pull
and throws it out of sync after every push.
It is kind of inconvenient to clone a fresh repo each time after a PUSH
has been done.
Any advice.
Recently I also raised this issue. I believe that issue has some connection to this one.
Ok I am answering my own question here.
In my opinion what might have happened is that link to remotes (references to remote repositories ie do git branch -a
. The branches that begin with "remotes/*" is what I am referring here) remained "stale" for some reason I do not understand.
Before my suggestion as a quick check try these steps:
git status
should throw message
# On branch master
# Your branch is ahead of 'origin/master' by X commit(s).
#
blah blah blah...
when I see this message my instinct is to do a push
git push remote master
...in this case I was working on master, for which I get
Everything up-to-date
which maybe confusing and I go and do a git status
for which the same message reappears:
# On branch master
# Your branch is ahead of 'origin/master' by X commit(s).
#
blah blah blah...
use push -f
option and check git status
to see if the message disappears.
If you still get the same confusing(but correct) message you should probably be suspicious of your remote.
One of comments in a related question pointed me in the right direction.
listing the steps here:
git remote -v
throws output
origin gerrit:project (fetch)
origin gerrit:project (push)
From gitref add your remotes here and remove origin
git remote add gerrit gerrit:project
git remote rm origin
git remote -v
which should show following:
gerrit gerrit:project (fetch)
gerrit gerrit:project (push)
Now do a push -f
as follows
git push -f gerrit master
will probably yield Everything up-to-date
...but this time it really meant it ;-)
on git status
receive
# On branch master
nothing to commit (working directory clean)
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.