Changing the brunch of previous commits.

Guys, i am new to git and sourcetree - was using it only for 1 week, thank you for a great tool!

I started with master branch and made 10 commits. After i've read on proper work flow - i liked githubflow more than git flow - i realized that all this commits must be in different brench.

Basically same starting point(init commit) for [master] and [x-feature] branches, but all commits after 1st one must be in [x-feature] branch not the [master] branch.

Is there a way to change branch of already done commits?

1 answer

0 vote

Hi Den!

Undoing a commit can be a complex operation and the benefits you'll get are not that big. You can leave the current commits like that, and start with the new workflow from now onwards.

Anyway, if you'd like to go ahead with this you can do an interactive rebase. With the interactive rebase tool, you can stop after each commit you want to modify and change the message, add files, or do whatever you wish (like adding it to a new branch in your case). You can learn more about how to use interactive rebase at Rewriting History.

Keep in mind that if your commits have already been pushed to a central server, it's not recommended to perform this operation, as doing so will confuse other developers by providing an alternate version of the same change.

Lastly, this is more a matter of Git than SourceTree. If you have more GIt questions in the future, you can address them to the Git section within our Community :)

Hope this helps! 

Ana

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

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

411 views 0 1
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