27

I want to be able to sync a work repo from my Windows 7 desktop to my Windows 7 laptop without pushing my commits to our main server. How do I do this? I can't figure out how to set up a remote path so that git can understand where it is. I generally use Git Bash for dealing with git, not the windows commandline, so the issue here is likely that I can't figure out how to write a path in Git Bash which will reference a windows share.

So, say I have a repo at (windows share path):

\\\\MyWorkPCName\dev\myrepo\

And in the command line, I can access the directories and files (albeit using pushd since cmd is stupid), how do I convert this in to a valid git remote?

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Charles Randall
  • 6,920
  • 12
  • 33
  • 38

1 Answers1

43

While Git doesn't recognize backslashes, Windows does recognize forward slashes:

git remote add desktop //MyWorkPCName/dev/myrepo

Git Bash also lets you access windows drives using UNIX-style paths, e.g. C:\Users\bug\repo becomes /c/Users/bug/repo.

bug
  • 904
  • 9
  • 11
  • 1
    Unfortunately this was the very first thing I tried. I get "fatal: Not a git repository (or any of the parent directories): .git" Also, I can't cd to a share directory from within git bash. Maybe part of the problem? – Charles Randall Feb 01 '12 at 22:41
  • 2
    Try running that line from a `cmd` prompt (unless you installed msysgit with the "Git Bash only" option) and/or using `file://\\MyWorkPC\etc` (with single quotes if using bash). – bug Feb 02 '12 at 00:26
  • 4
    Your original answer was correct. Flaky network may be an explanation for why it wasn't working for me originally. – Charles Randall Feb 02 '12 at 17:00
  • The answer is correct. Note that "Not a git repository" may also indicate you're not in a git repository locally (duh!) – Nickolay Feb 02 '13 at 00:11