使用Git/Github for Windows,如果我有一个存储库的这个目录:C:\dir1\dir2,我需要做什么来移动回购文件到C:\dir1?显然,我可以物理地复制和粘贴文件,但在Git端需要做什么呢?

我在GitHub上有这个回购,我使用Git Bash和GitHub for Windows。


当前回答

未来报告:2018年4月。

我想在我的Mac和Windows上规范化我的本地回购,它们最终在不同的本地文件夹中。

Windows 10客户端让我经历了“找不到”、“>”、“定位”的例行程序,乏味但并不可怕。还需要在选项中更新本地“克隆路径”以供将来使用。

当我合并mac文件夹时,Github客户端又发现了它们-我什么都不用做!

其他回答

只需复制整个工作目录的内容(包括隐藏的.git目录)。这将把整个工作目录移动到新目录,并且不会影响GitHub上的远程存储库。

如果你正在使用GitHub for Windows,你可以使用上面的方法移动存储库。但是,当您单击应用程序中的存储库时,将无法找到它。要解决这个问题,只需单击带!的蓝色圆圈,选择Find It,然后浏览到新目录。

I use Github Desktop for Windows and I wanted to move location of a repository. No problem if you move your directory and choose the new location in the software. But if you set a bad directory, you get a fatal error and no second chance to make a relocation to the good one. So to repair that. You must copy project files in the bad directory, make its reconize by Github Desktop, after that, you can move again your project in another folder and make a relocate in the software. No need to close Github Desktop for that, it will check folders in live.

希望这能帮助到一些人。

这对我没用。我将一个repo从(例如)c:\project1\移动到c:\repo\project1\, Git for windows没有显示任何变化。

Git状态显示错误,因为其中一个子模块“不是Git存储库”,并显示旧路径。例如(为保护知识产权而更改名称)

C:/project1/.git/modules/subproject/subproject2 致命:“git状态—瓷器”在子模块子项目失败

我必须手动编辑子模块中的.git文件,以指向子模块的repo的正确相对路径(在主repo的.git/modules目录中)

虽然前面的答案似乎都说你可以移动目录,在.git结构中没有绝对路径。当我使用Cygwin的git时,我发现这是不真实的。

当我移动我的git回购时(实际上我从备份中恢复了它,但由于我的驱动器结构在新系统上发生了变化)。我收到了一条错误信息

fatal: Invalid path '<part_of_the_original_repo_path>': No such file or directory

我使用grep在我的.git/配置文件[core]部分中找到了一个工作树变量,它保存了我的git repo的绝对路径。改变这一点为我解决了问题。

更基于Git的方法是使用cd或复制粘贴对本地副本进行更改,然后将这些更改从本地存储库推到远程存储库。

如果您尝试检查本地回购的状态,它可能会显示“未跟踪的更改”,这实际上是重新定位的文件。要强制执行这些更改,您需要使用

$ git add -A
#And commiting them
$ git commit -m "Relocating image demo files"
#And finally, push
$ git push -u local_repo -f HEAD:master

希望能有所帮助。