4

Using Git on Windows, I'm trying to deal with content that's external to my git repo. We have artwork and content files for instance that are being updated by non git-users in google drive so to capture these changes I've setup something similar to the following;

d:\MyRepo
  \.git
  \code1
  \images1
  \fonts (junction) => c:\users\%username%\google drive\designerLtd\fonts
  \etc

Where 'fonts' is a folder has been linked using either junction.exe or mklink /j (same thing). This generally works out great because Git status immediately highlights new changes (either on purpose or by accident) and prepares them for checkin or undo.

ISSUE: sometimes when switching branches Git prunes the linked directories and re-creates them if content in those folders is different between branches. In effect it breaks the link. Now Git is always correct and the build is consistent but it's not always obvious that it is no longer keeping track of those external resources.

Worse still, it can delete files in the external location. They can be recovered from git of course, but it's very unwieldy.

Swapping the content in the external locations when branches are switched isn't a problem, because there's only one PC that's hooked up this way and they're easily merged, but I just wish it didn't break the links.

QUESTION: Is there a better way to allow external junction points within a Git repo on Windows?

To be clear, there are no symlinks in the GIT repository (yet) as far as I know and this isn't a question about interoperability between Unix and Windows git clients (which most of the other questions on SO seem to relate to).

Brian Burns
  • 20,575
  • 8
  • 83
  • 77
cirrus
  • 5,624
  • 8
  • 44
  • 62
  • I am experiencing the very same problem. Have you found a way to get around it? – Ali Feb 20 '17 at 04:35
  • 1
    Not exactly. I just created a script to restore/reset the links. It's not ideal. Making the git repo the master and linking into it rather than the other way around is best, but links within the repo are very messy otherwise. – cirrus Feb 21 '17 at 15:59

1 Answers1

1

You can modify permissions of the junction point so that git can no longer delete it. Git usually doesn't care if removing a directory fails (except if it needs to replace the directory with a file).

See "Usage Recommendations" in https://support.microsoft.com/en-us/kb/205524