The distributed version control system is used more and more frequently in the daily development, who has not experienced the shaking, accidentally put the wrong content git push to the remote repository?
A few days ago I met, then not familiar with git, so various try ... Finally, it's clear now.
Environment:
Operation:
Git pull Origin master (burying the curse and pulling down other people's commits)
git push self master:master
Repo in the merge request, including someone else's commit!
Workaround:
New temporary branch git checkout-b newmaster
Version return git reset Beaforeyourcommitnum (do not use--hard ha)
git add *; git commit-m "BlaBla ..."
Git pull--rebase Origin master
git push self master:newmaster
Repo, find setting, change Defalt branch to Newmaster ( no obsessive-compulsive children's shoes can end, ha, the operation is to change the main branch to master)
Repo and local both delete master
git push self master:master (create a new remote master)
Repo and local delete newmaster git branch-d newmaster ()
The above is my blood lesson (Saturday overtime, not good ~), welcome to study advice, may God bless you all!
This article is from the Internet of Things blog, be sure to keep this source http://wulianwang.blog.51cto.com/3351843/1592772
Resolve GIT push remote branch errors