How can I ignore directories or folders in Git using msysgit on Windows?
相关问题
- Inheritance impossible in Windows Runtime Componen
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
- I want to trace logs using a Macro multi parameter
相关文章
- 请教Git如何克隆本地库?
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
to instruct GIT to ignore certain files or folders, you have to create
.gitignore
file.but in windows explorer you have to provide a name for the file, you just cannot create file with just extension, the trick is that create a empty text file and go to command prompt and change the name of the file to
.gitignore
now open the file with your favorite text editor and add the file/folder names you wish you ignore. you can also use wildcards like this
*.txt
hope it answers you question
On Unix:
On Windows:
These commands executed in a terminal will create a
.gitignore
file in the current location.Then just add info to this
.gitignore
file (using Notepad++ for example) which files or folders should be ignored. Save your changes. That's it :)More information: https://www.atlassian.com/git/tutorials/saving-changes/gitignore
By default windows explorer will display
.gitignore
when in-fact the file name is.gitignore.txt
Git will not use
.gitignore.txt
And you can't rename the file to
.gitignore
because explorer thinks its a file of type gitignore with no name.Non command line solution:
I assume the problem is that your working tree is like:
... with the
.gitignore
you describe. This will give yougit status
output like:... if the
index.html
files have not yet been added to the repository. (git sees that there are unignored files in the cache directories, but only reports the directories.) To fix this, make sure that you have added and committed theindex.html
files:... and your
git status
will then look like:(Obviously you do want to commit
.gitignore
as well, I was just being lazy with this test case.)Create a file named
.gitignore
in your project's directory. Ignore directories by entering the directory name into the file (with a slash appended):More info here.
It seems that for ignoring files and directories there are two main ways:
.gitignore
.gitignore
file into the root of your repo besides.git
folder (in Windows make sure you see the true file extension and then make.gitignore.
(with the point at the end to make empty file extension) )~/.gitignore_global
and runninggit config --global core.excludesfile ~/.gitignore_global
to add this to your git confignote: files tracked before can be untracked by running
git rm --cached filename
Repo exclude - For local files that do not need to be shared, you just add the file pattern or directory to the file
.git/info/exclude
. Theses rules are not commited, so are not seen by other users more info here[updated] To make exceptions in list of ignored files, see this question.