stackjlei
stackjlei

Reputation: 10035

How do I have git not track .vscode/ or .gitignore file changes?

I just started using vscode editor and when I checked git status I saw that it has the warning of the .vscode/ file not being tracked. How do I have it ignore this? When I added this to the .gitignore file, it then said I made changes to the .gitignore file. I always thought that this file would automatically be ignored by git and wouldn't be tracked as its changes should only ever be saved to my local copy?

Upvotes: 1

Views: 3375

Answers (2)

Kaka Ruto
Kaka Ruto

Reputation: 5125

If you don't want to change the .gitignore file, you can create rules that will only apply to you.

You can use this rule for locally generated files, that you don't expect others to generate, such as files created by your editor.

Open this file called .git/info/exclude within the root of your Git repository(project dir) and add your rules.

If you have vim, you can do so with vi .git/info/exclude

Any rule you add here will not be checked in, and will only ignore files for your repository.

Upvotes: 0

Attie
Attie

Reputation: 6979

.gitignore is something that should be under version control. This way all people who checkout the project will also be persuaded away from trying to commit their .vscode/ directory.

.gitignore is not specific to your environment, but rather the repository.


If you really don't want to put this rule in the repo's .gitignore, then you can setup a per-user ignore file:

git config --global core.excludesfile $HOME/.gitignore

Upvotes: 8

Related Questions