使用Git/Github for Windows,如果我有一个存储库的这个目录:C:\dir1\dir2,我需要做什么来移动回购文件到C:\dir1?显然,我可以物理地复制和粘贴文件,但在Git端需要做什么呢?
我在GitHub上有这个回购,我使用Git Bash和GitHub for Windows。
使用Git/Github for Windows,如果我有一个存储库的这个目录:C:\dir1\dir2,我需要做什么来移动回购文件到C:\dir1?显然,我可以物理地复制和粘贴文件,但在Git端需要做什么呢?
我在GitHub上有这个回购,我使用Git Bash和GitHub for Windows。
当前回答
-首先检查当前文件夹中包含git repo的所有目录 $ ls -la或者ls -al
-识别这个文件夹
**.git**
-使用此命令移动文件夹到您需要的位置,
$ mv .git你想要的目录
注意:>目录不会影响git的历史记录,也不会影响远程连接 考虑要移动到的目录的树(路径)
其他回答
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.
希望这能帮助到一些人。
如果你正在使用GitHub桌面,那么只需要执行以下步骤:
关闭GitHub桌面和所有其他打开文件的应用程序到当前目录路径。 如上所述,将整个目录移动到新目录位置。 打开GitHub桌面,点击蓝色(!)“仓库未找到”图标。然后将打开一个对话框,你将看到一个“Locate…”按钮,它将打开一个弹出窗口,允许你将其路径指向新的位置。
未来报告:2018年4月。
我想在我的Mac和Windows上规范化我的本地回购,它们最终在不同的本地文件夹中。
Windows 10客户端让我经历了“找不到”、“>”、“定位”的例行程序,乏味但并不可怕。还需要在选项中更新本地“克隆路径”以供将来使用。
当我合并mac文件夹时,Github客户端又发现了它们-我什么都不用做!
虽然前面的答案似乎都说你可以移动目录,在.git结构中没有绝对路径。当我使用Cygwin的git时,我发现这是不真实的。
当我移动我的git回购时(实际上我从备份中恢复了它,但由于我的驱动器结构在新系统上发生了变化)。我收到了一条错误信息
fatal: Invalid path '<part_of_the_original_repo_path>': No such file or directory
我使用grep在我的.git/配置文件[core]部分中找到了一个工作树变量,它保存了我的git repo的绝对路径。改变这一点为我解决了问题。
如果你使用Visual Studio,使用Teams Explorer > Connect选项卡> Local Git Repositories中的Add来将现有的本地回购带到可用的回购中。不吵闹,不麻烦。