只克隆 git repo 的 .git 目录

问题描述:

我有一个与 google Drive 同步的存储库,但我忽略了 .git 目录,所以它现在上传到了 Google Drive.

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

最近我格式化了我的 Gentoo 机器,在我再次同步所有 Google Drive 文件后,我意识到 .git 目录不在那里.

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

问题是我不记得我是否在本地有一些未提交/未提交的更改未推送到 github.

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

我一直在搜索,但我只找到了相反问题的答案(没有 .git 目录的克隆)

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

在我确定可能的本地更改不会丢失之前,我不想对我的 repo 制作 git clone.

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.

有没有办法只克隆 .git 文件夹,然后推送我机器上可能有的任何本地更改?

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

我解决了.这是一个简单的过程:

I solve it. It was an easy process:

  1. 我已将存储库克隆到其他位置,例如(在 /tmp 中)
  2. 我已将 .git 文件夹复制到我的原始 repo 文件夹中
  3. 我在我的原始 repo 文件夹上做了 git status 并且所有本地更改都在那里.
  1. I've cloned the repo to a different location eg (in /tmp)
  2. I've copied the .git folder into my original repo folder
  3. I did git status on my original repo folder and all the local changes were there.

希望能帮到别人