Search code examples
gitgit-pushgit-commit

How to merge pushed two commits?


I committed and pushed some files via git commit . followed by git push.

Then, I found that there were some mistakes in the files. I fixed ti. Then, I recommitted and re-pushed. So, I now see two separate commits in git log, which is ugly.

Can I merge these two pushed commits into one?


Solution

  • Yes you can. If no one else has pulled from the remote you can:

    git rebase -i
    

    Followed by:

    git push origin +master
    

    Please keep in mind that it is not recommended to rebase shared repositores and that +master will ignore it being fast forward.