Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo git update-index --assume-unchanged <file>

I have run the following command to ignore watching/tracking a particular directory/file:

git update-index --assume-unchanged <file> 

How can I undo this, so that <file> is watched/tracked again?

like image 978
adardesign Avatar asked Jun 19 '13 15:06

adardesign


People also ask

What does git update index do?

Overview. We use git update-index when we want to manually operate on files in Git staging area. This command supports two options that are often misused: –assume-unchanged and –skip-worktree. In this tutorial, we'll see how these two options differ and provide a use case for each.

What is Skip Worktree?

--skip-worktree explained: This allows you to make changes to a file that you don't want to be pushed to upstream. Use this option as already shown above.

What is assume unchanged in eclipse?

When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index.


2 Answers

To get undo/show dir's/files that are set to assume-unchanged run this:

git update-index --no-assume-unchanged <file> 

To get a list of dir's/files that are assume-unchanged run this:

git ls-files -v|grep '^h' 
like image 188
adardesign Avatar answered Sep 28 '22 04:09

adardesign


If this is a command that you use often - you may want to consider having an alias for it as well. Add to your global .gitconfig:

[alias]     hide = update-index --assume-unchanged     unhide = update-index --no-assume-unchanged 

How to set an alias (if you don't know already):

git config --configLocation alias.aliasName 'command --options' 

Example:

git config --global alias.hide 'update-index --assume-unchanged' git config... etc 

After saving this to your .gitconfig, you can run a cleaner command.

git hide myfile.ext 

or

git unhide myfile.ext 

This git documentation was very helpful.

As per the comments, this is also a helpful alias to find out what files are currently being hidden:

[alias]     hidden = ! git ls-files -v | grep '^h' | cut -c3- 
like image 43
adswebwork Avatar answered Sep 28 '22 04:09

adswebwork