Error when checking out a branch in SourceTree for Windows

When checking out a branch in SourceTree for Windows I get this error:

git -c diff.mnemonicprefix=false -c core.quotepath=false checkout master
Switched to branch 'master'


git -c diff.mnemonicprefix=false -c core.quotepath=false submodule update --init --recursive
bash.exe: warning: could not find /tmp, please create!

/libexec/git-core/git-sh-setup: line 266: cd: .git: No such file or directory

Unable to determine absolute path of git directory

Completed with errors, see above.

It still checks-out the branch but it gives this error everytime. It also gives me this error when I try to stash something but it will not let me stash anything when I get this error.

6 answers

1 accepted

It looks like my instance of git that is installed has some variables set incorrectly that SourceTree uses. I went to settings and changed SourceTree to use the embedded version of git and it's working now.

This might be related to submodules which we don't fully support in the Windows version yet, but I have a repo with a submodule here as a compatability test and I don't see this error when I switch branches. Can you check if your submodules are configured correctly?

If I may piggy-back on this question for a moment, my project has nested submodules and I am still trying to figure out how much submodule support the current SourceTree for Windows has.
Your FAQs states: "Submodule support isn't 100% yet; they should keep in sync but you can't configure them and some subtleties won't be dealt with yet"

I don't see any hint of my submodules in a repo that I imported from using in TortoiseGit.
I am expecting the same "Submodules" node under the "Remotes" and "Stashes" nodes.

I cloned a fresh copy of the repo and do see it checking out submodules, but again I don't see any "Submodules" node.

Right now under the hood SourceTree for Windows does the minimum necessary to co-exist with submodules; so when you clone a repo with submodules it will use --recursive to clone them too, it will also show when you change the submodule tracked commit and will let you stage & commit that change, but there is no explicit UI representation of the submodules in the sidebar tree, nor can you create or manipulate the submodule configuration. This is all coming and will mirror the Mac version when it's done.

I don't have submodules but I do have more info. I tried to clone another repository and got this message:

git -c diff.mnemonicprefix=false -c core.quotepath=false clone --recursive https://user@bitbucket.org/account/repo.git "C:\Users\User1\Documents\repo"
Cloning into 'C:\Users\User1\Documents\repo'...

bash.exe: warning: could not find /tmp, please create!

/libexec/git-core/git-sh-setup: line 266: cd: .git: No such file or directory

Unable to determine absolute path of git directory

Completed with errors, see above.

I also went to another repository and opened the terminal from SourceTree and it had error messages too:

base.exe: warning: could not find /tmp, please create!

ERROR: HOME directory 'C:\Users\User1' doesn't exist!

This is an error which might be related to msysGit issue 108.
You might want to set the environment variable HOME explicitly.

Falling back to / (C:/Program Files (x86)/Git).

Hmm, I don't have HOME explicitly set either although I do have the Windows standard ones HOMEDRIVE (C:) and HOMEPATH (\Users\Steve). If HOME isn't defined then Git Bash will usually define HOME based on those two. Is your environment missing HOMEDRIVE and HOMEPATH?

I had exactly the same problem (message complaining about HOME, submodules not working) with the embedded version. I don't know if related, but external conflict resolving didn't work either.

I had to kill sh.exe, then delete git_local and then redownload the embedded git (just renaming it and redownloading did not help).

That sounds like it didn't extract properly for some reason the first time. Were there any permission errors when you were trying to delete git_local?

I couldn't delete git_local because it was in use (by sh.exe, of course) but I still could rename it (Windows is strange). After killing sh.exe I could delete it without problems.

But the problem started totally unprovoked, I didn't do any update updates or the like. SourceTree doesn't automatically update the embedded Git, does it?

Nope, only when you click 'Update Embedded Git' in Tools > Options > Git. Very odd.

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 Tuesday in Uncategorized

Friday fun: how many celebrates Midsummer holiday or is this a Swedish tradition only?

Any other country that celebrates Midsummer holiday (this friday 22 June)?  

37 views 3 1
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