2

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?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
user1167777
  • 91
  • 2
  • 8

2 Answers2

2

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:

enter image description here

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.

Barnaby Golden
  • 4,176
  • 1
  • 23
  • 28
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
1

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?)

Community
  • 1
  • 1
Rey0bs
  • 1,192
  • 12
  • 19