0

We are using git work flow with a develop branch for integration and feature branches for individual features.

  1. Created a feature branch via:

    git fetch
    git checkout -b new-branch origin/develop
    

(develop is our working integration branch)

  1. worked on new branch and when ready created pull request back into develop and created a pull request on github and merged.

    there were no merge conflicts and now our feature branch lives on develop

  2. Had to do another pull request for tweaks to code

  3. at the end of the sprint we reverted the new-branch out of develop via github - using the revert button on the pull request page.

  4. when we tried to revert the second pull request github was unable to do it, so we reverted this commit manually via:

    git checkout develop
    git fetch
    git merge --ff-only origin/develop
    git revert -m 1 commit ##the commit that was the pull request
    git push
    
  5. when we did the above step we (unexpectedly) got merge conflicts; which we solved; and now YAY! new-branch is no longer on develop, our commits were reverted.

  6. Now that we have released, we want to continue to work on new-branch and remove the revert which as we understand it there are two different ways to do so.

    1. revert the commit that removed the pull request
    2. find out the commit prior to where we forked the new-branch and run

      git rebase -i --no-ff commit
      
  7. nether of these are allowing us to re-introduce new-branch into our develop branch.

rlc
  • 2,808
  • 18
  • 23
Adam
  • 85
  • 1
  • 8

1 Answers1

0

if you have all the code you want on your release branch you should either:

  • branch of of that if it has all the changes you need and work on that branch

  • merge it to develop and then branch off develop if there is code on develop you want to keep

then you can just delete the old branch

I you are wanting to remove the reverted commit, don't. Generally, removing or changing commit history in git is a considered a bad idea https://sethrobertson.github.io/GitBestPractices/#pubonce

finally Git Choose Your Own Adventure is an amazing resource for fixing git follies...

Ben Glasser
  • 3,216
  • 3
  • 24
  • 41
  • Short story is that we reverted our feature branch out of develop so we could make release, so that we could release on time. Now that we are in a new sprint we can continue to work on the feature and are wanting it back in develop. We want to avoid using push and instead use merge, but there is nothing to merge because git compares commits - which are the same because the revert is a commit that removes the code - not the history. – Adam Jun 17 '15 at 22:42
  • so if you revert the revert, what happens? – Ben Glasser Jun 17 '15 at 22:49
  • I get a merge conflict in almost every file – Adam Jun 18 '15 at 16:03