Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maestrow/c69627afc75d6f809bc2 to your computer and use it in GitHub Desktop.
Save maestrow/c69627afc75d6f809bc2 to your computer and use it in GitHub Desktop.
Git checkout from a specific directory
# http://stackoverflow.com/questions/17833185/git-checkout-from-a-specific-directory
# Method №1
mkdir <repo.git>
mkdir <working-dir>
git clone <repo-url> <repo.git> --bare --depth 1
git --git-dir=<repo.git> --work-tree=<working-dir> checkout HEAD -- <repo-subdir>
# Method №2
mkdir <working-dir>
cd <working-dir>
mkgir .git
git clone <repo-url> .git --bare --depth 1
git --work-tree=. checkout HEAD -- <repo-subdir>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment