6

I have a remote repo called FOO which has the two following revisions :

commit1 commit2

I have a directory 'bar' which contains all the files for commit2 but I am missing the .git directory and all metadata.

Is there a way for me to 'git clone' only the '.git' metadata from the remote into my current directory without the files?

The main goal is to avoid wasting time checking out files since I already have them.

Any suggestions ? Thanks in advance.

Mark Fisher
  • 965
  • 1
  • 11
  • 30
user3009900
  • 61
  • 1
  • 3
  • This question is a duplicate of [Clone only the .git directory of a git repo](https://stackoverflow.com/q/38999901/11725753) – EvgenKo423 Apr 24 '21 at 15:05

1 Answers1

24

git clone -n

-n will tell git not to checkout the head after performing the clone.

customcommander
  • 17,580
  • 5
  • 58
  • 84
Spencer
  • 932
  • 13
  • 22
  • Note that it doesn't restore the index, so if you just move the `.git` directory into the working tree `git status` output will be incorrect. – EvgenKo423 Apr 24 '21 at 16:19