git-ls-tree和git-ls-files中的git差异,或者,将删除的文件推送到另一个git的正确方法是什么
在我的repo中,我发现有一些文件不存在于git-ls-tree和git-ls-files中的git差异,或者,将删除的文件推送到另一个git的正确方法是什么,git,Git,在我的repo中,我发现有一些文件不存在于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$ git log <deleted file1 commit msg is t
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$ 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
~/repo$git日志
~/repo$git ls树
~/repo$git ls文件
~/repo$find-名称文件1
~/repo/file1
所以看起来file1仍然存在于repo目录中,尽管在workspace目录中,file1被删除、git-rm'ed、committed并推送到repo
如何将一个git目录中已删除或重命名的文件推送到另一个git目录
提前感谢:)不要推到非裸存储库中 您更改了
~/repo
的repo状态,但未更改工作目录。当您在repo
中git status
时,您将看到git认为您手动进行了一些更改,因为您的repo状态与您的工作目录/索引不匹配
如果要消除差异,需要在repo
中运行git reset--hard
。但这将消除您在工作目录中所做的任何更改
你不应该一开始就推到repo
。您应该只推送到裸repo(没有工作副本的存储库)。您可以从非裸回购中提取。因此,将wsp
中的更改转换为repo
的正确方法是进入repo
并从wsp
中提取
或者您需要推进非裸回购有什么具体原因吗?您正在从
~/vcs/project1
克隆并推进它,为什么要检查~/repo
?git ls tree
需要您提供一个树,git ls tree
刚刚向您展示了使用指南吗?另外,git-ls-tree
不会递归运行,除非您提供-r
。如果git-ls-files
在~/repo
中工作,则表示这是~/vcs/project
的另一个非裸克隆。您需要合并/重置/重新设置/签出某些内容,以便将更改从~/wsp
推送到~/repo
@shahbaz的工作目录中,edited@CharlesBailey为了澄清这一点,我正试图推动我以前克隆过的回购协议。我发现进行“合并”只会更新树/索引,而不会更新实际文件,至少在删除文件的情况下是这样。我正在尝试为我的团队设置git repo。没有具体原因说明我不应该进入“回购”和退出“wsp”。谢谢