在我的资源库中,我发现有一些文件在git ls-tree中不存在,但在git ls-files中存在。我所做的是:在工作空间目录中
~/wsp$ git clone ~/repo/project1
~/wsp$ rm project1/file1
~/wsp$ git add -A
~/wsp$ git commit -m'deleted file1'
~/wsp$ git push在repo目录中
~/repo$ git log
<deleted file1 commit msg is there>
~/repo$ git ls-tree
<file1 is not in ls-tree>
~/repo$ git ls-files
<file1 is still there!>
~/repo$ find . -name file1
~/repo/file1因此,看起来file1仍然存在于repo目录中,尽管在工作空间目录中,file1被删除、git-rm‘’ed、提交并推送到repo。
如何将一个git目录中已删除或重命名的文件推送到另一个git目录?
提前感谢:)
发布于 2013-04-29 22:18:29
不会推入非裸存储库。
您更改了~/repo的存储库状态,但没有更改工作目录。当你在repo中使用git status时,你会看到git认为你手动做了一些修改,因为你的存储库状态与你的工作目录/索引不匹配。
如果你想消除这种差异,你需要在repo中运行git reset --hard。但这将清除您在工作目录中所做的任何更改。
您一开始就不应该推送到repo。您应该只推送到裸存储库(没有工作副本的存储库)。您可以从非裸repos中拉取。因此,将wsp中的更改保存到repo中的正确方法是进入repo并从wsp中提取。
或者,您需要推送到非裸回购有什么特殊的原因吗?
https://stackoverflow.com/questions/16279874
复制相似问题