Skip to content

Instantly share code, notes, and snippets.

@zaus
Last active December 12, 2015 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaus/4733163 to your computer and use it in GitHub Desktop.
Save zaus/4733163 to your computer and use it in GitHub Desktop.
Common GIT commands for different scenarios?
# clone repository to current working directory (cwd)
git clone "{{repo}}" .
# clone a repository to the current directory, "symlinking" git files elsewhere, checking out single file
git clone -n --separate-git-dir="{{extpath}}\{{ProjectName}}" "{{path}}\{{ProjectName}}" .
git checkout HEAD {{file}}
## Explanation:
## 1. git
## clone
## -n no files checked out, just history; could use `--bare` as well?
## --separate-git-dir={{extpath}} where to put the `.git` directory, not cwd
## {{path}} the repository to clone
## . use current working directory -- won't work if not empty
## 2. git
## checkout
## HEAD latest
## {{file}} the filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment