Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
6.4k views
in Technique[技术] by (71.8m points)

github - Clone only the .git directory of a git repo

I have a repo in sync with google Drive, but I had the .git directory ignored so it is now uploaded to Google Drive.

Recently I formatted my Gentoo machine and after I had all Google Drive files synced again I realized the .git directory was not there.

The problem is I do not remember if I had some unstagged/uncommited changes in local not pushed to github.

I have been searching but I only found answers for the opposite question (Cloning without the .git directory)

I do not want to make a git clone of my repo until I am sure that possible local changes are not going to be loss.

Is there any way of cloning only the .git folder and then push any local changes that I may have in my machine?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The one-step solution would be:

git clone --no-checkout <repo_url>

or if you already have an empty dir for it,

cd myrepo
git clone --no-checkout <repo_url> .

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...