'.gitignore only on local
I would like to know how to gitignore files but only on local, without pushing it (because the other people working on the project should not get this update of gitignore of files I added there.
To be simple, after a git status I only have :
modified: .gitignore
because I added my files to ignore to my gitignore but well now I want the line above gone without pushing it.
Solution 1:[1]
Gitignore file should be committed because in most cases what you ignore would be ignored by other developers in the team too.
But if you absolutely need to exclude it from being tracked for local changes, you could do the following:
git update-index --assume-unchanged .gitignore
This will make it "disappear" from the modified list. Though if someone else changes it, you will not get the changes on pulling. You'll then need to do the below to bring it back to tracked list and do a pull again:
git update-index --no-assume-unchanged .gitignore
Solution 2:[2]
Another option in VSCode is to use Git Exclude extension which basically add any file/folder using right click to your .git/info/exclude file
Solution 3:[3]
.gitignore file contains the list of files & folders that are to be prevented from getting committed/pushed to the remote repo.
But, it is always acceptable to commit & push .gitignore file. And it is a very common practise. So, commit the .gitignore file and move ahead with your code.
Read this thread for reference/good practises about committing .gitignore file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vasan |
| Solution 2 | Tamir Gilany |
| Solution 3 |
