gitgit-addgit-stagegit-rm

How do I move an unstaged file to untracked?


Say this is what I'm looking at in git status:

Changes not staged for commit:
    modified:   Makefile.in

Untracked files:
   ../node_modules/somepath/inverter_packet.js

What I want to do is something like move Makefile.in from 'Changes not staged for commit' to 'Untracked files.'

I know I can ignore changes with git update-index --assume-unchanged Makefile.in, and get them back with the --no-assume-unchanged command, but I'd rather not have these files completely out-of-view, because I do edit/commit them once in a while.

I want to remove files from the 'not staged' section, but still see it when I type git status.

Alternately, if I could (preferably simply) stop showing the diff for unstaged files (e.g. like my Makefile.in up there) when typing git diff, that would also be good.


Solution

  • I want to remove files from the 'not staged' section, but still see it when I type git status.

    Where do you want them moved to? There really are no other places to hide.

    As you mentioned, these are tracked files, so you don't want to remove them from the repo with git rm, that would be plain wrong. The only real option here is to have them assumed unchanged. They'll be "out of view" either way, so the question doesn't really make much sense.

    One other option is to stash only that single file using git stash -p but then you'll lose the changes in your working copy until you pop the stash back, which again, is not what it seems you're going after.