Reputation: 10040
I pushed some changes to our central git repository, and then immediately realized that I had an old, now obsolete change lying around, and that I had introduced a merge with it:
I then used git rebase to get rid of this spurious parent:
Then I pushed this with git push -f
to origin. It answers with "everything up-to-date".
Now I would expect the central repository to match what I have locally. However, when I clone
the project anew, I still have the spurious parent inside. What's worse is that git wants to merge, and if I let it do that, I get my latest commit twice (once with the old hash, and once with the new one after rebasing).
How do I get git to push what I have without merging, and just take my repository state as the new state (so basically, to reject all remote differences)?
or am I doing this wrong? I want to get rid of the "When reading a property..." commit, and the whole red line in the upper image.
Upvotes: 2
Views: 1295
Reputation: 133008
You can solve this in various ways. One way is to reconstruct the history locally by using reset, stash and commit. The following will undo your last commit (Initial import of the...) and stash away those changes.
git reset --mixed HEAD^
git stash
Now you can reset your master to the commit you had before you did the merge, assuming abcd1234 is the hash of the "Testing git." commit:
git reset --hard abcd1234
Now bring back the stash and commit it again:
git stash pop
git add .
git commit -m 'Initial import of the C++ client library.'
Now finally push up your rewritten master:
git push -f origin master
Upvotes: 1