aahnik
aahnik

Reputation: 1881

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?

Upvotes: 0

Views: 603

Answers (2)

Chuck Lu
Chuck Lu

Reputation: 191

It would be better to use git push --force-with-lease.
git push --force-with-lease vs. --force

Upvotes: 1

Shridhar R Kulkarni
Shridhar R Kulkarni

Reputation: 7063

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

Upvotes: 1

Related Questions