有没有办法让忽略的文件显示在 git status 中?
有没有办法在 Git 中标记文件,例如“git add .”不会暂存它,但它仍然显示在 git 状态下吗?
我知道这听起来很疯狂,但原因是我有一些本地脚本文件,我想在我的 git GUI(Tower)浏览窗口中看到它们,但是当我“暂存所有”时,我不希望将它们添加到存储库中。
如果我取消跟踪文件并设置状态 showUntrackedFile = Normal (或全部),它们就会显示出来,但随后它们会被“git add”添加回来。或“全部上演”。如果我将它们放入 .gitignore 中,它们将不会被添加/暂存,但它们也不会显示在浏览窗口中(至少在塔中实际上是 git status)。
有没有办法让被忽略的文件显示在 git status 中?我猜不会,但我希望有一个切肉刀能解决问题吗?
Is there a way to mark a file in Git such that a "git add ." won't stage it but have it still show up under git status?
I know this sounds crazy, but the reason is I have some local script files that I'd like to see in my git GUI (Tower) browse window, however I don't want them added to the repo when I "stage all".
If I untrack the files and set status showUntrackedFile = Normal (or all) they show up, but then they get added back in by "git add ." or "Stage All". If I put them in .gitignore they won't get added/staged but they won't show up in the browse window either (which at least in tower is effectively git status).
Is there a way to get ignored files to show up in git status? I'm guessing no, but am hoping for a cleaver work around?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定其他回答者是否正在阅读该人,但是:
也显示了被忽略的文件。
http://www.kernel.org/pub/software /scm/git/docs/git-status.html
I am not sure if the other answerers are reading the man, but:
shows ignored files as well.
http://www.kernel.org/pub/software/scm/git/docs/git-status.html
您可以创建一个调用
git status
的 别名和git ls-files -o -i --exclude-standard
状态后...有点像黑客,但它应该可以工作。
我刚刚测试了这个,它有效
设置别名:
git config --global alias.st '!git status && echo "**忽略的文件**" && git ls-files -o -i --exclude-standard'
运行
git st
而不是git status
类似问题
如何调用多个命令别名
You could create an alias that calls
git status
andgit ls-files -o -i --exclude-standard
after status...Kind of a hack, but it should work.
I just tested this and it works
Set the alias:
git config --global alias.st '!git status && echo "**IGNORED FILES**" && git ls-files -o -i --exclude-standard'
Run
git st
instead ofgit status
Similar question
How to call multiple commands in an alias
我不这么认为;这实际上会破坏 gitignore 的意图。
来自 http://git-scm.com/docs/gitignore
我知道这可能不是您希望的答案,但我认为它是准确的。
I don't think so; that would actually break the intent of git ignore.
From http://git-scm.com/docs/gitignore
I know it's probably not the answer you're hoping for, but I think it's accurate.