Programming

How to skip a file in git without getting committed

Let’s say you have local changes to a file that you do not want to commit to the repository. Assume it is a configuration file and you want to build locally with different settings.

When you change the config file it is always show up when you try git status command. then you you have to revert it back to its original file to commit it.

Git has two solutions for that and it is –skip-worktree

–skip-worktree is useful when you instruct git not to touch a specific file ever because developers should change it. For example, if the main repository upstream hosts some production-ready configuration files and you don’t want to accidentally commit changes to those files, –skip-worktree is exactly what you want.

Example:

git update-index --skip-worktree <filename>

when you want to remove it

git update-index --no-skip-worktree

What’s your reaction about this article?
+1
0
+1
0
+1
0
+1
0
+1
0

Leave a Reply

Your email address will not be published.