Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - Temporarily ignore trivial changes to files

Tags:

git

ignore

I'm looking for a way to 'hide' minor changes made to a few files in Git, such that they will not show up in git status until a different change is made to those files.

Example: I have a java file where the only change made is the removal of an unused import (a contributor forgot to run an organize imports before committing). Now I have removed that import and the change (obviously) shows up in git. Since I have no other change to make to that file, I don't really like committing the file as part of another (unrelated) change or committing this change stand-alone. Sure, I could revert the change and only applying it whenever I will have to make changes to that file, but I could "risk" forgetting it.

Does a command exists for such a task? It would work somewhat like the assume-unchanged command but in a not permanent way.

What would be the proper way to resolve this if no such command is available?

Thanks in advance.

like image 870
Zelgadis Avatar asked Nov 18 '12 16:11

Zelgadis


1 Answers

In my use case (developing using an edited config file on my personal machine, running on another machine with the unchanged config), this was the solution for me:

start ignoring changes to a file:

git update-index --assume-unchanged path/to/file 

keep tracking again:

git update-index --no-assume-unchanged path/to/file 
like image 59
benroth Avatar answered Sep 29 '22 04:09

benroth