我的Git存储库位于错误的根目录中。我可以移动它吗? (../ 代替 。/) [英] My Git repository is in the wrong root directory. Can I move it? (../ instead of ./)

查看:89
本文介绍了我的Git存储库位于错误的根目录中。我可以移动它吗? (../ 代替 。/)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知何故,当我在一个月左右之前编辑了我的最新项目时,我在比目录更高的目录下运行了命令。

>

因此,我的存储库位于 ./项目目录中,而不是 ./ project / my-新项目目录。我不知道我早些时候怎么没有意识到这个问题,但直到现在我才从未寻找.git目录。



有没有办法,不会造成死机我的项目,将存储库移动到适当的目录,然后告诉git项目的新基础是什么?只是移动目录不起作用。 Git认为所有的文件都被删除了。 可能是最简单的事情,除非你已经创建了一些你想保存的历史记录,只需要删除 .git 子目录,然后在正确的目录中重新初始化。



如果你使用git为了解决这个问题,任何解决方案都必须留下很多移动这个文件到这里的历史条目,这些条目实际上并没有改变,但是你在创建时修复了一个错误。最好只是创建它。


Somehow when I git inited my latest project a month or so ago I ran the command in the directory one directory higher than the root of my project.

So my repository is in the ./project directory and not the ./project/my-new-project directory. I don't know how I didn't realize the issue earlier, but I just never looked for the .git directory until now.

Is there a way, without killing my project, to move the repository to the proper directory and then tell git what the new base of the project is? Just moving the directory doesn't work. Git thinks all files have been deleted.

解决方案

Probably the simplest thing, unless you have already created some history you want to save, would be to just delete the .git subdirectory and redo the init in the correct directory.

If you used git to solve the problem, any solution would necessarily leave behind a lot of "moved this file here" history entries that aren't actually changes, but you fixing a screwup at creation time. Better to just create it right.

这篇关于我的Git存储库位于错误的根目录中。我可以移动它吗? (../ 代替 。/)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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