1

This is a follow up to my previous question here:

Fix history after forced push

The question was why after forced push, history is not synchronized in other developers repositories. The answer was that other developers, after executing git pull will have their local history merged with the one from server. So if I removed a commit from the top and force pushed it, then it will still be there at the top in other developers repositories.

Now to the point, today I have been testing this scenerio once again (this time with company git server - it uses gerrit). And I see that above history merge does not happen.

What I have done:

I have a central repository, I have cloned it to two local folders. I have created a remote branch for testing, then pushed to it few commits. The log for them looked as follows:

git log --preety=oneline
962937062641327e4ad9d83ee7ead97f6c5a3bc7 One test change
08667125120a39b24c2006d5a63f6e1be61828a4 Code fixes - extra comment
...

Then made sure both of the local repositories are synchronized.

Then in local reposotory, lests say repo1, I have removed top commit with:

git reset --hard 086671251

and pushed repo1 with git push -f origin HEAD:dev/mike-test3

Then in the second local repozitory, I have executed git pull, and now what puzzles me is that commit 962937062 was actually removed, below is what git gave me on output:

git pull
remote: Counting objects: 10, done
remote: Finding sources: 100% (6/6)
Unpacking objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
From [...........]
 + 9629370...0866712 dev/mike-test3 -> origin/dev/mike-test3  (forced update)
   18ab880..bc08478  master     -> origin/master
First, rewinding head to replay your work on top of it...

Even git status shows me no pending commits to be pushed.

I have changed a commend slightly from the one in my previous question. From git reset HEAD^ --hard to git reset --hard SHA1, the previous one just didnt work for me (shouldnt HEAD^ be HEAD~1?).

Community
  • 1
  • 1
mike
  • 1,670
  • 11
  • 21

0 Answers0