Skip to content

Instantly share code, notes, and snippets.

@brianddk
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save brianddk/a5ef486532155fd99795 to your computer and use it in GitHub Desktop.

Select an option

Save brianddk/a5ef486532155fd99795 to your computer and use it in GitHub Desktop.
Git Server-less repo / remote setup

#Git Server-less repo / remote setup This is an example of how to setup two directories to serve as a local and remote in the GIT protocal. Basically GIT is like the old RCS system where all things are filesystem based. All the SSH and HTTPS sugar are just spice

###Demo.cmd walkthrough

  • First 13 lines just set up directories.
  • Line 14 creates the remote repo (bare for remote).
  • Line 17 creates the local repo (no bare here).
  • Line 18 adds the remote repo that we set up in line 14 as a 'file://' url.
  • Next we create a file, add it and commit it
  • Line 22 we push with the '-u' option sticking the remote 'origin' and the branch 'master'
  • Create another file to add and commit
  • Line 26 we don't need to name the remote or branch since we 'stuck' it earlier

###Notes This example uses files on your local filesystem, but you could easily make them remote files with with the windows \\server\share\directory syntax, though you will need to know how to code the file URL. For windows shares (from windows) it would look like 'file://\\server\share\directory'

###Credit I stole this from Jimmy Hill's blog post [archive]

###Shortcuts

setlocal
set root=%cd%
set repo=testRepo
set local=%root%\local
set remote=%root%\remote
set localRepo=%local%\%repo%
set remoteRepo=%remote%\%repo%.git
set firstFile=FirstFile.txt
set secondFile=SecondFile.txt
mkdir %local%
mkdir %remote%
mkdir %localRepo%
mkdir %remoteRepo%
cd %remoteRepo%
git init --bare
cd %localRepo%
git init
git remote add origin file:///%remoteRepo%
echo first file> %firstFile%
git add %firstFile%
git commit -m "First File Commit"
git push -u origin master
echo second file > %secondFile%
git add %secondFile%
git commit -m "Second File Commit"
git push
endlocal
@brianddk
Copy link
Author

brianddk commented Apr 4, 2015

May go without saying, but spaces in the directory path will likely mess this up

By @d4n13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment