有没有办法使用命令git ls-files,只显示未跟踪的文件?
我问的原因是因为我使用以下命令来处理所有已删除的文件:
git ls-files -d | xargs git rm
Run Code Online (Sandbox Code Playgroud)
对于未跟踪的文件,我想要类似的东西:
git some-command --some-options | xargs git add
Run Code Online (Sandbox Code Playgroud)
我能够找到-o选项git ls-files,但这不是我想要的,因为它也显示了被忽略的文件.我还能够提出以下长而丑陋的命令:
git status --porcelain | grep '^??' | cut -c4- | xargs git add
Run Code Online (Sandbox Code Playgroud)
似乎我必须在这里使用更好的命令.如果没有,我如何创建自定义git命令?
根据帮助,没有-x选项git clean应该更不用说被忽略的文件,但事实并非如此.
[il@reallin test]$ cat .gitignore
*.sar
[il@reallin test]$ mkdir -p conf/sar && touch conf/sar/aaa.sar
[il@reallin test]$ git status
# On branch master
nothing to commit, working directory clean
[il@reallin test]$ git clean -df
Removing conf/
Run Code Online (Sandbox Code Playgroud)
conf/sar/aaa.sar已移除.这是一个错误吗?