How can I join two pushed commits?
For example: I have a commit fixing a typo and a commit changing a text file. I want to join both and keep only the one which says "changing a text file" on the commit log.
How can I do it?
How can I join two pushed commits?
For example: I have a commit fixing a typo and a commit changing a text file. I want to join both and keep only the one which says "changing a text file" on the commit log.
How can I do it?
Generally, you can use
git rebase -i
andfixup
to rewrite the history and merge commit 2 into commit 1.Because you already pushed the changes, beware that it is generally not recommended to rewrite the history after the changes has been pushed to a remote repository, because other clients may have already downloaded the changes and you may cause troubles with future updates.
If you are fully aware of what you are doing, use
rebase
to rewrite the history, and push the changes with the--force
flag:git push -f
.