Git re-clone to existing folder with files
My Obsidian vault on another machine does not have .git
so I have to re-clone only the .git
folder. Use --no-checkout
to clone only .git
to a temporary path, then move it out.
git clone --no-checkout https://github.com/narze/second-brain temp_git
mv temp_git/.git .
rmdir temp_git
If some files are still missing, like .gitignore
, you can restore them with git checkout HEAD
git checkout HEAD -- .gitignore
git reset