right way to create a new branch

hi all! I had a problem creating a new branch and after go back to the previous:

I've created a new branch called dev_NP from my branch dev, after I've used dev_NP and the next commit are all of dev_NP.

on the website I see that all the old commit have both dev and dev_NP:

today I checked out my dev branch to continue to work in dev, but it mantained also the changes made in dev_NP, so I made some bad things with git reset git revert...

how can I do this in the right way?

thanks in advance

5 answers

This widget could not be displayed.

I think to advise you we need a clearer understanding of what it was you were trying to achieve - can you explain?

This widget could not be displayed.

Hi Steve!

In my project I worked on the 'dev' branch.

after I've created a new branch called 'dev_NP' from the last commit of 'dev' branch.

after this, all the 'dev_NP' commits are referenced in the bitbucket website like the image that I posted, 'dev' and 'dev_NP'.

Today I decided to come back to the 'dev' branch and leave the 'dev_NP' branch, so I checkout the 'dev' branch, sourcetree told me that the actual branch was 'dev' but it mantained all the commits that I made in 'dev_NP'

Yeah, that doesn't sound normal - if you created a new branch dev_NP and checked it out, any new commit would have been associated with that branch, and checking out 'dev' again should have taken you back to the previous point in time. Can you show us a screenshot of SourceTree's graph?

This widget could not be displayed.

I'll do it at home, here is modified after the git reset and git revert, but the graph is a single line

This widget could not be displayed.

here is the shoot

That looks completely normal to me. The Bitbucket view should only show the branch alongside the commit if the commit is reachable from that branch - the only thing I can think of is that you did some kind of history modification (like reset to commit) but after you'd already pushed those commits, then you pushed them again? Hard to visualise how this view matches up since I can only see part of your BB list in the previous screenshot.

This widget could not be displayed.

thanks steve!

but is right that when you create a new branch, in bitbucket website you see the label 'new_branch' also for the old commits and when you commit in the 'new_branch' you see also the label of the other branch?

Yes, it's because they are 'reachable' from that branch I believe. You'd have to ask the Bitbucket guys for more detail on that design decision :)

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...

879 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