79

Paths to network resources are denoted in Windows with the \\servername\share\path\to\folder syntax. How does one use such a folder within Git Bash, which uses Unix-style paths?

Cerran
  • 1,817
  • 2
  • 19
  • 30
Florian von Stosch
  • 1,522
  • 1
  • 13
  • 22

5 Answers5

93

Actually just cd //servername/share/path/to/folder where //servername/ is followed by at least one shared folder.

protometa
  • 1,354
  • 10
  • 16
  • 7
    ... and there's nothing special about ```cd``` here. One can access the share right from a bash script, i.e. as ```find //10.10.10.10/backup -type f -name "*.source" | zip -@ -9 b.zip```. – mgaert Oct 22 '15 at 14:11
  • Under Win10, if you use elevated cmd prompts as well as git bash, you should match the elevation level of the git (bash) with the level of the cmd window creating the share. Otherwise the mapped drive (implicit with the cd approach from protometa or explicitly as with Florian von Stosch) won't be available : can take a few minutes to sort out. – simon coleman Nov 13 '17 at 09:15
  • 2
    It's probably worth noting that you reversed all the slashes (relative to OP) in order to make this work. – Brent Bradburn May 03 '18 at 21:35
  • hmm, from an sshd `bash.exe -l` shell, it says Function not implemented, it does work from the desktop; any ideas how to get this to work over ssh? – ThorSummoner Dec 20 '20 at 22:55
18

You need to associate a drive letter to the network path you want to use. To do this, execute the following command in the Windows cmd shell:

pushd \\servername\share\path\to\folder

The next prompt will carry the assigned drive letter, e.g. Z:\path\to\folder. Now, open Git Bash (it will not work with an already running instance) and go to the new created drive letter:

cd Z:/path/to/folder

or equally

cd /z/path/to/folder
Florian von Stosch
  • 1,522
  • 1
  • 13
  • 22
  • 4
    Nice touch with ```pushd```. Of course, a plain ```net use N: \\\\10.10.10.10\\backup``` seems to work, too, with a *specified* drive name. – mgaert Oct 22 '15 at 14:02
8

Actually

git clone //servername/path/to/repo.git

works fine for me (using git version 1.9.0.msysgit.0)

Ajasja
  • 739
  • 1
  • 15
  • 20
3

If you need it for cloning, more appropriate answer is here:

git clone file:////<host>/<share>/<path>

Notice the word file and 4 slashes after it, that is the trick.

Community
  • 1
  • 1
i--
  • 4,211
  • 2
  • 24
  • 35
  • This should be the accepted answer, if all you did was create a repository on the network drive like `git init --bare \\host\share\repository-name.git` `git clone file:////host/share/repository-name` – paulecoyote Jan 06 '17 at 23:23
2

No need to type the path manually. Just right click! on your repository and click Git Bash option. It will open the git bash with your repository path.

enter image description here

Also i suggest to use Mp Network Drive option of windows to map the network location as a drive and use it only.

027
  • 1,281
  • 9
  • 20