I just did git rebase -i HEAD~5, wanted to fixup/squash 2 of my commits... then had to force push and now my remote branch has one commit of mine and 4 of someone else. WTF. please help, how to remove the other 4 commits of someone's else?! I just want it to have that one commit of mine.
Asked
Active
Viewed 724 times
2
-
Please [edit] your question and include a diagram of the recent commits. Identify the ones you want to keep and the ones you want to remove, and also show one commit beyond that. – ChrisGPT was on strike Aug 07 '16 at 18:51
-
doing git rebase -i HEAD~5 again shows me a list of 9999 commits, do i need to stash every of them manually?! – katarina Aug 07 '16 at 22:44
-
That seems like a lot, and also a very interesting number. You really need to include some screenshots or otherwise share more information before we can help you. – ChrisGPT was on strike Aug 07 '16 at 22:48
-
Possible duplicate of [Git commits are duplicated in the same branch after doing a rebase](http://stackoverflow.com/questions/9264314/git-commits-are-duplicated-in-the-same-branch-after-doing-a-rebase) – Whymarrh Aug 08 '16 at 00:42
2 Answers
1
When you do a git rebase -i HEAD~5
you also get all the commits in a merge.
You had a merge commit
so you had more commits that the actual 5 commits.
For example:
here is the log screenshot + the git rebase -i HEAD~5
which results in 17 commits.
You can follow the log and count the 5 commits on the most left branch and you will see that all the other commits are "collected" on the way as well.

CodeWizard
- 128,036
- 21
- 144
- 167
-
-
1you can add the `--preserve-merges` but it will show all teh commits in range. `git rebase -i HEAD~5 --preserve-merges` as far as i know you cant avoid it since its a rebase with all of it sequences – CodeWizard Aug 07 '16 at 22:57