Skip to main content

Git Repo in share folder

·1 min

Sometimes you just want to push your Git into empty folder. The easiest way is to create bare repo for Git in destination folder. Below is the step to create it:

  1. Go to your local git repo location.
cd c:\local\myLocalRepo
  1. Change your directory to target share drive using command pushd.
pushd \\remoteServer\git\shareFolder\Path
  1. Create a folder for your repository.
mkdir myServerRepo
cd myServerRepo
mkdir .git

It is a best practice to create bare init inside .git folder.

  1. Go to .git folder and initiate repo.
cd .git
git init --bare
  1. Go back to your previous folder.
popd
  1. Add remote path and push it
git remote add origin \\remoteServer\git\shareFolder\Path\myServerRepo
git push origin master

Congratulation you are created a bare repo in share folder. The only down side is you cant see your file there (because we are using –bare flag). If you want to see the file, you can clone it to other folder.

Henry Thomas
Author
Henry Thomas
Just a guy with a pen and a dream