It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

SourceTree Push, Stash pull request, Reverting Merges

Aaron Shelley Jul 30, 2013

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

1 vote
Answer accepted
Aaron Shelley Jul 31, 2013

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?

Charles O'Farrell Aug 01, 2013

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

0 votes
Charles O'Farrell Jul 31, 2013

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

0 votes
Aaron Shelley Aug 01, 2013

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

Thanks for the help.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Sourcetree

[dev team] Sourcetree for Windows 2019 Preview - Dark Theme

Hi folks, While the full post is over on our blog I'd like to share the dark theme we've got planned for 2019 here directly as well to keep the discussion going.  The ...

1,890 views 14 18
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you