Best practice when pulling story branches from git

We have recently started using GIT and our process is for each task/story (agile) we create a branch.

In some cases branches that have been merged need to be pulled from a release. What is the best way to do this?

Coming from TFS we used labels and it was easy to point specific items to an older changeset but with GIT I am not sure how to best do this. Seems like it would be easy if it was the last push but if there are 10 pushes after I have to undo all of those and then do another pull request with just the ones I want?


You can return on branch state before the merge to restore merged branch :

git reflog
git checkout <last_feature_commit_number>
git checkout -b <feature_branch>

Then update this new branch on your release branch

git pull --rebase origin <release_branch>

If you have conflicts, resolve it, add files in stage and execute git rebase --continue

You can view commits you prepare to merge with git log <release_branch>..<feature_branch>

Finally merge this branch in release branch :

git checkout <release_branch>
git merge <feature_branch>

Assuming your local machine hosts the merge commit. If not, you can try to get remote reflog but I don't know if it always is possible (see git can I view the reflog of a remote? and Can I recover branch after its deletion in git?)


I suggest that you use git flow.

The git flow model is a suitable model and will answer all your questions.

Read all about it here http://nvie.com/posts/a-successful-git-branching-model/ and once you have finished your reading you will be better able to understand the following diagram:

在这里输入图像描述

The "catch" with git flow is that there are full scripts which take care of each step you make along the way so it is hard to make mistakes.

链接地址: http://www.djcxy.com/p/49836.html

上一篇: 合并失败后恢复为分支?

下一篇: 从git中拉取故事分支的最佳实践