Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: hide/remove files never to be versioned

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.

like image 435
peterchen Avatar asked Aug 08 '09 12:08

peterchen


People also ask

How do I ignore a .cache file in git?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a .gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

How do you remove files that are listed in the .gitignore but still on the repository?

gitignore are not being tracked, you can use the git clean command to recursively remove files that are not under version control. Use git clean -xdn to perform a dry run and see what will be removed. Then use git clean -xdf to execute it. Basically, git clean -h or man git-clean (in unix) will give you help.

Will untracked files be committed?

Most untracked files will be staged and committed. Others will simply be ignored by including them in the . gitignore file. However, some files and directories will remain untracked, and in certain instances it can be useful to delete these untracked files from your Git repo.


2 Answers

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
like image 70
lemonad Avatar answered Oct 23 '22 14:10

lemonad


You need to investigate .gitignore files.

git help gitignore
like image 41
CB Bailey Avatar answered Oct 23 '22 15:10

CB Bailey