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

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

  •  03-06-2022
  •  | 
  •  

Domanda

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?

È stato utile?

Soluzione

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

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top