如何告诉 git 忽略对单个文件的所有进一步编辑而不将其从存储库中删除
我在 github 上分叉了一个项目,并开始在我自己的机器上搞乱它,我想将我所做的更改提交回我在 github 上的分叉,但不提交我对 .cfg 文件所做的更改,因为它包含诸如数据库密码等
I have forked a project on github and started messing around with it on my own machine, I want to commit the changes I have made back to my fork on github but without commiting the changes I have made to the .cfg file, since this contains things like db password etc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用这个:
并恢复:
最后,如果您想列出标有
skip-worktree
的文件:为了简化,您可以在
$HOME/.gitconfig 中为其创建一个别名
:然后您只需输入
git ls-ignored-changes
。如果您有git-completion
就位(对于 bash、tcsh、zsh)。
Use this:
And to restore:
Lastly, if you want to list files that are marked with
skip-worktree
:To simplify, you can make an alias for that in your
$HOME/.gitconfig
:Then you can type just
git ls-ignored-changes
. It even works with auto-completion if you have thegit-completion
in place (for bash, tcsh, zsh).