Configure git to ignore some files locally
In this short article, we will show you how to configure git to ignore some files locally.
Sometimes, You may need to exclude files from Git only on your computer. So you can use the simple git command to ignore the files locally without using the .gitignore
file.
Checkout more articles on Git
Ignore files
1 | git update-index --skip-worktree <FILE-LIST> |
Unignore files
1 | git update-index --no-skip-worktree <FILE-LIST> |
Get the list of ignored files
1 | git ls-files -v | grep ^S |
Install git aliases
You can install git aliases to make it simpler. It will update your aliases node of your config file.
1 2 3 | git config --global alias.ignore 'update-index --skip-worktree' git config --global alias.unignore 'update-index --no-skip-worktree' git config --global alias.ignored '!git ls-files -v | grep ^S' |
Now run the following commands to ignore/unignore or get ignored file list.
1 2 3 4 5 6 7 8 | // Ignore files git ignore <FILE-LIST> // Unignore files git unignore <FILE-LIST> // Get ignored files git ignored |
That’s it for today.
Thank you for reading. Happy Coding..!! 🙂