Error when checking out a branch in SourceTree for Windows
Asked by Kevin Jett:

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

```
git -c diff.mnemonicprefix=false -c core.quotepath=false checkout masterSwitched to branch 'master'git -c diff.mnemonicprefix=false -c core.quotepath=false submodule update --init --recursivebash.exe: warning: could not find /tmp, please create!/libexec/git-core/git-sh-setup: line 266: cd: .git: No such file or directoryUnable to determine absolute path of git directoryCompleted 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.


Answers:
author: Kevin Jett
body: 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.


author: Andr? H?nsel
body: 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).

comments: author: stevestreeting
body: 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?


author: Andr? H?nsel
body: 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?


author: stevestreeting
body: Nope, only when you click 'Update Embedded Git' in Tools \> Options \> Git. Very odd.


author: stevestreeting
body: 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?


author: Kevin Jett
body: 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 directoryUnable to determine absolute path of git directoryCompleted 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).
```


author: Paul Peavyhouse
body: 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.

comments: author: stevestreeting
body: 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.


author: stevestreeting
body: 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?


Tags: windows