git checkout 。添加稀疏 checkout 排除的目录

标签 git sparse-checkout

在稀疏 checkout 场景中,命令 git checkout . 恢复应该忽略的目录。这是设计使然,还是 Git 中的潜在问题?我正在使用 git checkout . 放弃我对我的工作副本所做的任何更改——是否有另一个命令可以执行相同的操作并且不会遇到这个问题?

这是一个可重现的例子:

rm -rf test
git init test
cd test
for f in a b c; do
  mkdir $f
  touch $f/$f
  git add $f/$f
  git commit -m "added $f"
done
git config core.sparsecheckout true
echo a > .git/info/sparse-checkout
echo b >> .git/info/sparse-checkout
git read-tree -m -u HEAD
ls
a b

到目前为止,还不错。问题是:

git checkout .
ls
a b c

顺便说一句:

git --version
git version 1.7.10.4

问题Why do excluded files keep reappearing in my git sparse checkout?是相关的,但要老得多,并不能完全描述我所看到的。

最佳答案

这不是设计使然。该行为有 changedGit 1.8.3 .

关于git checkout 。添加稀疏 checkout 排除的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15251638/

相关文章:

git - tortoisegit = 致命的 : the remote end hung up unexpectedly but not with git bash

git - 让 IntelliJ IDEA 在 Windows 上使用公钥认证

android - 推送错误 : master: master [rejected non-fast-forward]

github/git Checkout 在 Windows 上返回 'error: invalid path'

android - 有用的提示和技巧 "checkout"(下载)安卓源码更快速

git - Jenkins 稀疏 checkout : only content of directory

linux - 在 Git post-receive hook 中杀死 Grunt 进程

git - 如果 git 中的分支需要 rebase ,如何务实地检查 bash 脚本?