如何使用 git-gui (tcl-tk) 应用程序忽略文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22046808/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to ignore files using git-gui (tcl-tk) application?
提问by édouard Lopez
I'm using the git-gui
interface to manage my git
project. Despite being ugly –tcl-tk
– it's one of the most complete interface out there.
我正在使用该git-gui
界面来管理我的git
项目。尽管很丑 - tcl-tk
- 它是最完整的界面之一。
However, I can't find how to ignore files from this interface ?
但是,我找不到如何从该界面忽略文件?
回答by Daniel Schmidt
the pragmatic way is, to add this to your git
configuration:
实用的方法是,将其添加到您的git
配置中:
git config --global guitool."Add to .gitignore".cmd $'echo "\n$FILENAME" >> .gitignore & git add .gitignore'
git config --global guitool."Add to .gitignore".needsfile yes
git config --global guitool."Add to .gitignore".confirm yes
Usage
用法
After that, you can use it under Tools > Ignore selected file
in your git gui
.
Select a file you want to ignore under Unstaged Changes -> Tools/ignore selected file
之后,您可以Tools > Ignore selected file
在您的git gui
. 在下面选择要忽略的文件Unstaged Changes -> Tools/ignore selected file
回答by Dan Hoerst
If you mean ignore them forever, then add a .gitignore
file in the root of your directory (where the .git
folder is). List the files or file types separated by a new line like so:
如果您的意思是永远忽略它们,请.gitignore
在您的目录(.git
文件夹所在的位置)的根目录中添加一个文件。列出由新行分隔的文件或文件类型,如下所示:
*.pyc
venv
.metadata
If you mean ignoring it temporarily, you can do the .gitignore
step or just stage the files you want to commit individually.
如果您的意思是暂时忽略它,您可以执行该.gitignore
步骤或仅暂存您要单独提交的文件。
回答by Abby Fichtner
If you set it in your .gitconfig file, the GUI will comply.
如果您在 .gitconfig 文件中设置它,GUI 将遵守。
Add this to your .gitconfig
(should be located under c:\users\USERNAME)
将此添加到您的.gitconfig
(应位于 c:\users\USERNAME 下)
[core]
excludesfile = ~/.gitignore
Then create a file c:\users\USERNAME\.gitignore
然后创建一个文件 c:\users\USERNAME\.gitignore
and add the ignore files to that.
并将忽略文件添加到其中。
回答by David Nguyen
You can try to add all the files first. After that go to git gui, choose those files you want to ignore in "Staged Changes" and press Ctrl-U.
您可以尝试先添加所有文件。之后转到 git gui,在“暂存更改”中选择要忽略的文件,然后按 Ctrl-U。