SourceTree Push, Stash pull request, Reverting Merges

I think I've been screwing up my pushes to my team's repository. Whenever I make a pull request for a new feature branch that I just pushed, all previous feature branches are attached to the newest pull request.

I think what is happening is, after I push a feature, I finish the feature and it gets merged to my develop branch. Then I create a new branch from develop (which has the previous feature merged to it) and after I push and do a pull request, the previous feature branch is attached to my new pull request.

So my question is, how do I revert the merge of a feature branch to my develop branch after having finished and deleted the feature branch?

What is a good practice for pushing new feature branches and closing them out when finished?

Right now I...

create new branch, commit changes, push, pull request, finish/delete branch.

create new branch after finish/delete of old branch and continue with above steps.

So when i'm tackling 5 features, one after the other, I get 5 pull requests each containing the previous feature's commits.

Do I need to wait to finish/delete my feature branches until after the pull request is merged?

I.E.

create new branch, commit, push, pull request

create new branch, commit, push, pull request

create new branch, commit, push, pull request

branch 1 and 3 are merged

finish/delete branch 1 and 3?

3 answers

1 accepted

This widget could not be displayed.

Thanks for the reply.

I think I figured out what I was doing wrong. After I made a pull request I would finish my branch (before pull request was merged) which would merge my branch back to my local develop branch. Then when I created a new branch and did another pull request it would see that I made a merge with previous branch and tack that on to my new pull request.

I'm still learning so I don't know what the best practice is when doing this.

Currently, when I need to make a new branch, I'll do a pull from origin/develop to my local develop.

Then I will git flow > new feature branch.

Commit/push branch

Pull request branch to be merged with develop

Branch is merged

then I delete my local feature branch.

Everything appears to be working smoothly now that I'm follow the above steps. Does this appear like a correct method of using SourceTree?

Hi Aaron,

I'm not quite sure what you mean 'finish' the branch? Either way, yes doing a pull and making sure your local develop is up to date before creating a new feature branch is the correct thing to do. You can even have multiple feature branches open in parallel, the trick is to branch from origin/develop and not include changes on other un-merged feature branches.

Good luck.

Charles

This widget could not be displayed.

Hi Aaron,

I just need to clarify what you mean what you say "containing the previous feature's comits'. In some sense that's exactly what you would expect - when you branch from 'develop' after a merge by definition any new branches will contain the previous feature branches commits. However, after the merge I wouldn't expect to _see_ the commits in the PR 'commits' tab, because they should already exist in the target branch and be ignored.

What is a good practice for pushing new feature branches and closing them out when finished?

After you've merged you shouldn't have to do anything. We tend to tick the 'delete branch' button on the merge dialog because you don't need it any more, but it doesn't matter either way. You would also pull the latest changes down to your local machine (which should include a new merge commit on 'develop')

So my question is, how do I revert the merge of a feature branch to my develop branch after having finished and deleted the feature branch?

You definitely shouldn't need to revert anything.

If you have any screenshots of Stash and/or the commits/branches in question to demonstrate exactly what you mean that would be great.

Cheers,

Charles

This widget could not be displayed.

By 'finish' I meant using Git Flow > Finish Feature.

Thanks for the help.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

872 views 2 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you