How to make Git automatically ignore certain files when I'm staging changes? [duplicate]

StackOverflow https://stackoverflow.com/questions/17638921

  •  03-06-2022
  •  | 
  •  

Question

I have a folder in my Git directory that stores information about when my program runs and I don't want this information to keep getting added to the repo.

Currently I just avoid selecting files from this folder in the git gui. This can be very cumbersome however as there are often a lot of them. What is the best way to do this either using the gui or the command line?

Was it helpful?

Solution

Use the .gitignore file, note that you might have to exclude files with

 git rm --cached filename

from tracking, which were put there before you added the rule for them, see https://help.github.com/articles/ignoring-files

OTHER TIPS

Put the path to that directory into the .gitignore file, like this:

echo 'ignored-files/' >>.gitignore

Put the .gitignore file under version control if other developers might want to ignore those files as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top