Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MarceloZapatta/203baa34bb92ff2f2e88d2dfae6aca7d to your computer and use it in GitHub Desktop.

Select an option

Save MarceloZapatta/203baa34bb92ff2f2e88d2dfae6aca7d to your computer and use it in GitHub Desktop.
# https://stackoverflow.com/questions/2411031/how-do-i-clone-into-a-non-empty-directory
# Thanks: cmcginty, RichardC
git init
git remote add origin PATH/TO/REPO
git fetch
git reset origin/master # Required when the versioned files existed in path before "git init" of this repo.
git checkout -t origin/master
# If "git checkout -t origin/master" falls to "master already exists"
# Do this last two commands instead
git branch --set-upstream-to=origin/master
git ls-files -z --deleted | xargs -0 git checkout --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment