Changing the brunch of previous commits.

Den B May 16, 2017

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 votes
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 17, 2017

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
TAGS
AUG Leaders

Atlassian Community Events