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?

- 2,087
- 2
- 21
- 33

- 1,700
- 1
- 14
- 22
-
It's really not good to use git over samba if you can avoid it. It will be slow and breaks easily. – iveqy Nov 18 '13 at 12:38
-
9Still, it's useful for people who use git-bash as unix-environment replacement on Windows. – Wilbert Dec 04 '13 at 10:17
-
4Nobody mentioned using git over samba. Git bash != Git – robertmain Sep 13 '18 at 01:07
5 Answers
Actually just cd //servername/share/path/to/folder
where //servername/
is followed by at least one shared folder.

- 1,603
- 1
- 12
- 16
-
8... 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
-
3It'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
-
`cd //servername/share/path/to/folder` works like a charm! Provided that you must login first for example through `Run` by typing `\\servername` and providing username/password, otherwise it may show `Permission Denied`. – MD. Mohiuddin Ahmed Nov 03 '21 at 09:18
-
Even `cd //servername\share\path\to\folder` works. If you're copy/pasting, you only need to change the first two slashes. – wisbucky May 23 '23 at 10:50
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

- 1,700
- 1
- 14
- 22
-
5Nice 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
Actually
git clone //servername/path/to/repo.git
works fine for me (using git version 1.9.0.msysgit.0
)

- 809
- 1
- 16
- 21
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.
Also i suggest to use Mp Network Drive option of windows to map the network location as a drive and use it only.

- 1,553
- 13
- 23
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.
-
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