Multiple working folders for git on Windows XP

Tim Abell · November 16, 2011

Multiple working folders for git on Windows XP (lucky me)

It is assumed that you have a git working copy of your project already in place at C:\code\myproject\ and that you want another copy of your project sharing all history but with a different branch checked out at C:\code\othercopy\

This is useful for:

  • rapidly switching between branches where a switch would normally cause a time consuming recompile / rebuild
  • tracking the branch structure of Visual SourceSafe (which you aren’t using in this century are you?) aka VSS aka Visual Source Shredder (or maybe TFS)

This can be achieved by use of NTFS symbolic links (other related keywords: junction points, reparse points, hard links). Grab Sysinternals’ Junction to provide access to NTFS symbolic links. Extract the contents and put junction.exe on your path.

Word of warning for NTFS symbolic links in Windows XP:

  • Windows Explorer in XP doesn’t know about the NTFS symbolic links, and if you delete the containing folder it will delete the real copy of your linked folder (facepalm). Take backups first! You have been warned!

Open a command prompt and run the following commands:

cd c:\code\
mkdir othercopy
cd othercopy
mkdir .git
cd .git

junction hooks C:\code\myproject\.git\hooks
junction info C:\code\myproject\.git\info
junction logs C:\code\myproject\.git\logs
junction objects C:\code\myproject\.git\objects
junction refs C:\code\myproject\.git\refs

C:\code\othercopy\.git>copy C:\code\myproject\.git\* .

If you make a mistake, use junction -d to remove the branch point you have created, do not use explorer to delete a branch point as it will delete all your actual files.

You can now go into C:\code\othercopy\ and switch to a different branch, eg in git-bash:

cd c:
cd \code\othercopy\
git branch mynewbranch
git checkout -f mynewbranch

At this point you have two different checkouts sharing the same git data. Yay.

Word of warning for multiple working copies and git-extensions:

  • Git extensions gets confused if you remove a branch that one of your working copies is on; and incorrectly shows the folder as uninitialised. To resolve this use the context menu in explorer or the console to force checkout a different branch.

This howto was written with “git version 1.7.6.msysgit.0” and git-extensions v2.26.

References / see also

Share: Tweet | LinkedIn
Suggest improvments: page source on github