Skip to content

Instantly share code, notes, and snippets.

@ethomson
Created July 6, 2016 16:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethomson/8fdcfc61e039a20fa5c5d054c1eff44f to your computer and use it in GitHub Desktop.
Save ethomson/8fdcfc61e039a20fa5c5d054c1eff44f to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
# clone a bare repository, because even with `--no-checkout`, clone will create a
# folder for a working directory, and it will ignore the `--git-dir` option.
# but the restore all the configuration that would be there.
git clone --bare git@github.com:/ethomson/dotfiles .dotfiles.git
git --git-dir=.dotfiles.git config core.bare false
git --git-dir=.dotfiles.git config push.default simple
git --git-dir=.dotfiles.git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
git --git-dir=.dotfiles.git config branch.master.remote origin
git --git-dir=.dotfiles.git config branch.master.merge refs/heads/master
# redo the fetch, just to get the remote tracking branches setup
git --git-dir=.dotfiles.git fetch
# don't show any untracked files
echo '*' > .dotfiles.git/info/exclude
# checkout the working directory
git --git-dir=.dotfiles.git checkout HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment