Git - Moving Pushed Commits to a Different Branch

后端 未结 2 406
北恋
北恋 2020-12-23 13:34

My boss decided recently to try out an outsourcing group \"for increased capacity\" as we modify an existing application to add new features. Despite my concern that the gro

相关标签:
2条回答
  • 2020-12-23 14:15

    Getting the branch is easy:

    git branch their-branch master
    git reset --hard master $SHA1_OF_C
    git push --force $SHARED_REPO_REMOTE
    

    This will rewrite history; it creates a new branch that is equivalent to the current master branch named their-branch, then resets your local master to point to a random SHA1 (...or branch, or tag, or whatever), and finally forcibly updates the remote repository branch to match your local branch.

    That delivers exactly the situation you want.

    Caveats: this will rewrite history, and can screw up anyone who has built off the old master. Watch out for merge problems following.

    No rebasing desired or required.

    (As an aside, I suggest you either give them a staging repository, or get them to use git send-email, or use GitHub pull requests, or otherwise prevent them pushing to master until they get it right. Which, based on your summary, might be some time away.)

    0 讨论(0)
  • 2020-12-23 14:18

    Have them make a branch off of each bit of work from the same starting point for each ticket they work on. Have them merge the work to a RC branch. You can merge your work to the RC branch. This will allow you to test often. See the workflow we have here:

    https://plus.google.com/109096274754593704906/posts/R4qkeyRadLR

    Let me know if you have any questions about it. It works well for us.

    0 讨论(0)
提交回复
热议问题