简体   繁体   中英

Push local git commits history into origin branch

I work on project alone. I had in git log 5 commits. I merged these commits into one

git rebase -i HEAD~5
pick xxxx commit1
squash xxxx commit2
squash xxxx commit3
squash xxxx commit4
squash xxxx commit5

Now I have one commit in git log . Everything is nice. But I have after git status the next message:

Your branch and 'origin/master' have diverged,
# and have 1 and 5 different commits each, respectively.

I have to do git pull but after that I'll rewrite my git log to 5 commits again (I think).

To cut a long story short how can I push local git commits history into origin branch and get rid of the diverged error?

You can force your version of the history onto origin:

git push origin master --force

But please be aware that rewriting git history is frowned upon: http://git-scm.com/book/ch3-6.html#The-Perils-of-Rebasing

您需要合并原点/母版

git merge origin/master

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM