Search code examples
gitgithubgit-commitgit-rebasegit-reset

How to change the commit history in GitHub?


I have tried git rebase in interactive mode to squash commits. I have also tried git reset in soft mode, then made a single commit.

It seems to have changed my git log. But when I need to push to GitHub, It says could not push, I need to pull first due to divergent branches.

After pulling and then pushing, when I go to GitHub, I find that the number of commits has only increased.

How can I change the history on the commits page of a GitHub repo?


Solution

  • At this point

    It says could not push, I need to pull first due to divergent branches.

    you should do

    git push -f 
    

    This will get you the desired result. Hopefully other contributors, if any, on whatever you are working on, don't mind if the commit history has changes.

    Suggested reading: Git Push