Git LogoWorking on a project at Sanmark Solutions, I encountered a situation where I needed to clone a Git repository placed in a shared directory in a Windows machine into a working directory in a Linux machine. First I tried to do it with SSH, but I wasn’t successful. I guess that’s because I am not much experienced with that protocol. Then I decided to access the directory in Windows with Samba and mount it on local file system, and then clone, pull, and push from and to it considering it as a local location. This is how I did it:

Step 1: Install the required software.

We need Samba to connect to Windows shared directories.

sudo apt-get install samba
sudo apt-get install system-config-samba

Step 2: Create a mount point.

We need a place in our file system to mount the Windows directory.

sudo mkdir /mnt/directory_from_windows

Step 3: Mount the directory from Windows onto the created mount point.

We need to be able to access the directory from Windows through our mount point.

sudo mount -t cifs -o username=WindowsUsername,password=WindowsPassword //IPAddressToWindowsMachine/SharedDirectoryFromWindows /mnt/directory_from_windows

Here are what various flags to mount application in above command mean (Extracted from man pages.):

-t, --types

“The argument following the -t is used to indicate the file system type.”. So CIFS is the file system types used here.

-o, --options

“Options are specified with a -o flag followed by a comma separated string of options.”. We use the options username and password here.

Step 4: Verify the Windows shared directory is successfully mounted.


cd /mnt/directory_from_windows

and check whether you can see files from your Windows shared directory. If that works, you can go clone your Git repository, if not, you’ll have to troubleshoot.

Step 5: Clone your Git repository.

Go to the place where you need to create your working copy of the Git repository. In this example, I am assuming it’s your home directory.

cd ~

Then issue the command to perform the clone.

git clone /mnt/directory_from_windows


Bonus Step: Unmount mounted Windows shared directory.

If you need to unmount your mounted Windows shared directory, do:

sudo umount -a -t cifs -l