仅克隆git repo的.git目录 [英] Clone only the .git directory of a git repo

查看:64
本文介绍了仅克隆git repo的.git目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与Google云端硬盘同步的存储库,但是我忽略了.git目录,因此现在已将其上传到Google云端硬盘.

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云端硬盘文件后,我意识到 .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)

在确定可能的本地更改不会丢失之前,我不想对我的仓库进行 git克隆.

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.

希望对其他人有帮助

这篇关于仅克隆git repo的.git目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆