HeyHeyJC
HeyHeyJC

Reputation: 2867

How to put uncommitted changes on a new branch in SourceTree?

This question and others deal with this problem in Git, but I generally work only in the SourceTree IDE. I've done some work, but before committing it, I realizes it should be on its own branch. How do I do that without losing the work I've done?

Upvotes: 9

Views: 10719

Answers (2)

H45H
H45H

Reputation: 1017

Just click on Branch Icon
Give Name to your branch
Click OK
Your code will automatically will sync on your new branch.
then, If you want to commit your code on that branch
just commit it on your newly created branch. (The one with BOLD)

Upvotes: 11

HeyHeyJC
HeyHeyJC

Reputation: 2867

It works much the same in SourceTree as in command-line Git: your unstaged, uncommitted changes aren't affected when you create and checkout a new branch.

So right-click the previous commit in the Log/history, pick "Branch..." and enter a branch name. When you "Create Branch", your unstaged uncommitted work will still be there, and you'll be in the new branch.

Stage and commit your changes as per normal.

Upvotes: 9

Related Questions