Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Checkout new branch doesn't discard changes

Heymen Nicolaij December 9, 2015

In some branch I made some changes, but didn't add them to the index. 

Next I checked out a new branch to track a remote one and saw that the changes made while working on the first branch where still there. I would have expected them being discarded because now the local branch doesn't reflect the state of the remote branch.

Ok, but the problem is SourceTree has no option in de Checkout New Branch tab to discard/cleanup changes.

 

1 answer

0 votes
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 10, 2015

Git won't discard uncommitted files unless you explicitly tell it to. If the files that you changed are identical between the two branches (besides the uncommitted changes), Git will allow you to switch while keeping the changes (useful if you realized you were making the changes on the wrong branch, or just created a new branch for changes you were creating).

New files will always be kept as well, and Git should only complain if you try to check out a branch that has an indexed file with the same name/location.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events