Why does Sourcetree allow switching of branches with uncomitted changes. The "git checkout" doesn't

Sourcetree Version

I make changes in a branch, and forget to commit them (am new to git so haven't gotten into the habit).

I then use Source tree to switch to the next branch, which it quite hapily does.

I then find the code is exactly what it was with the other, uncommitted changes. Very confusing.

I then switched to the command line and tried a "git checkout" to the other repository and git wouldn't let me do it, saying there are uncommitted changes.

Why does Sourcetree allow it?



1 answer

0 vote

Hi Dave, I'm not sure I understand the problem you describe. I've tried to reproduce it using Git in the terminal and I've been able to switch to different branches even if I didn't commit my changes. Here's what I did:

  1. Created "branch 1" from master.
  2. Made some changes in this branch and didn't commit them.
  3. Switched to an existing "branch 2" successfully.
  4. Made some changes in this branch and didn't commit them.
  5. Created new "branch 3" and switched to it successfully.

Are those the steps you followed? If you're still having issues, can you clarify a bit more?

Best regards,


Hi Ana,

That is exactly the problem.

Sourcetree allows you to switch branches without committing your changes.  Git does not.  If at step 3 you try using command line git commands to checkout branch 2, it will not let you.

the git command and it's output is

C:\a_check>git checkout 02926D-A_add_comments_only
error: Your local changes to the following files would be overwritten by checkout:
Please commit your changes or stash them before you switch branches.

Sourcetree allows the checkout to 02926D thus confusing you over what changes are actually in the directory.

I did notice that if the changes are from a conflicted merge, Sourcetree will not allow the switch.



Hi Dave, that's weird, for my previous example I used only the command line git, I was not using SourceTree. Which git version are you using? I have git version 2.11.0 (Apple Git-81).



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
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

29,940 views 26 12
Join discussion

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