Reputation: 41116
I'm trying to get started using Git and TortoiseGit.
Is there a way to hide files that should never be tracked completely? Currently, all temporary build files are in the same "Not Versioned" list as new files when I commit a change.
Upvotes: 11
Views: 19737
Reputation: 20396
TortoiseGit can add files to the ignore list with many options.
Right click on a file in a repository → TortoiseGit → Add to ignore list → by filename / by extension
A dialog shows to choose options:
Ignore type
This file only (match absolute name),
Recursive (match same name)
Ignore file
.gitignore
in root directory (need to commit)
.gitignore
in included directory (need to commit)
.git/info/exclude
(like a configuration file, stored locally)
See also: Manual entry, Chapter 2. TortoiseGit Daily Use Guide, Ignoring Files And Directories.
Upvotes: 9
Reputation: 107387
Since one of the benefits of TortoiseGit is to use the UI, especially if you have used other products like TortoiseSVN and TortoiseHg, here are some UI ways to achieve this:
File not already added
An easy way to add files to the .gitignore
exclusions is when you are selecting files to be staged when you do a git commit
through Tortoise - Tortoise will list all non-ignored files which aren't currently in your repository under the Not Versioned Files
box at the bottom of the commit screen:
Unwanted file already added by mistake
If you've already committed or pushed the undesirable file, another way in newer (circa 1.8.14) versions of TortoiseGit to remove an existing file from your repository branch and add it to one of the .gitignore
s is hidden under the right mouse function Delete and add to ignore list
:
You then have several .gitignore
options to elect, either on whether to add just this file or wildcard matches, and to which .gitignore
to add it to - local folder, repository root, or your `.git/info/exclude'.
However, right at the last minute, you are given the opportunity to keep the local copy of the file:
Upvotes: 5
Reputation: 2435
In case you have files already added to the repository, but need to remove/ignore them, follow these steps:
Upvotes: 5
Reputation: 4208
Create a text file called .gitignore
in your root folder and add lines like the following to exclude files:
*.obj
test.c
Then add .gitignore to your Git repository and commit:
$ git add .gitignore
$ git commit .gitignore
Upvotes: 25