Background:
I have a feature branch A that is one commit ahead of my development branch:
3 (develop, origin/develop)
| 2 (A, origin/A) some feature branch commit
|/
1 some commit
Then I rebase A on develop (git checkout A
, git rebase develop
), so I get:
2' (A) some feature branch commit
|
3 (develop, origin/develop)
| 2 (origin/A) some feature branch commit
|/
1 some commit
Now I can no longer push A
to origin
as Git will reject a non-fast forward commit. It tells me to first pull the remote changes.
When I do so and then push, I end up with the following history:
4 (A, origin/A) merged origin/A into A
|\
2'| some feature branch commit
| |
3 | (develop, origin/develop)
| 2 (origin/A) some feature branch commit
|/
1 some commit
I end up with a history containing the 2
commit twice -- technically different commits although they do the same thing.
Questions
- How can I prevent this from happening? How can I mirror my local rebase operation on the remote repo?
- How can I remedy this situation? What would be the most elegant way to clean up the history and show only one commit?