loading...

How to change the commit history in GitHub?

aahnik profile image Aahnik Daw ・1 min read

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?

I need help !! Be the first to answer here ( in comment ) or in Stack Overflow

Discussion

pic
Editor guide
Collapse
aahnik profile image
Aahnik Daw Author

I got a solution on stack overflow ... Thanks to Shridhar R Kulkarni

git push -f will solve the problem of divergent branches.

After git rebase -i , using -f flag with push will change the commit history in GitHub commits page as desired.

Collapse
kallmanation profile image
Nathan Kallman

Instead of just -f consider the slightly better --force-with-lease.

It can save you from accidentally overwriting changes you didn't know had been pushed to the branch: thoughtbot.com/blog/git-push-force...