Search code examples
gitgit-bashmsys2

Change the location of /tmp in a Windows install of Git Bash


the TMP/TEMP directory in Windows 10 usually points to C:\Users\<user>\AppData\Local\Temp. When using Git bash, the /tmp directory "magically" refers to that location, too.

How can I change this behavior upon startup of the Git bash such that TMP, TEMP (for Windows programs started by Git bash) and the /tmp location refer to a different directory, e.g. C:/myTemp?

(Changing TMP or TEMP globally in Windows is not a viable option for me...)


Solution

  • In /etc/fstab, comment out any existing lines defining /tmp, and add this one:

    C:/myTemp /tmp ntfs auto
    

    The ntfs part doesn't matter because the system figures out the filesystem on its own. The auto part tells the system to mount it automatically when you start your shell. There are other options you might want to specify, like case sensitivity. For more information about that file, see:

    https://cygwin.com/cygwin-ug-net/using.html#mount-table

    After editing that file, you'll need to open a new shell.