Resolve GIT push remote branch errors

Source: Internet
Author: User

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:

    • Development project for Remote Warehouse Fork

    • Branch only Master

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.