5

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.

Nick Volynkin
  • 14,023
  • 6
  • 43
  • 67
J.M. Janzen
  • 671
  • 1
  • 8
  • 19
  • 2
    Untracked files means files which are not being version controlled by git at all. So I guess the only way to make the changes end up in "Untracked files" section would be to stop tracking them. `git rm --cached -- ` `git commit`. However, since you state that occassionally do commit the file, I am assuming that this is not what you want to do. – Alderath Jun 17 '15 at 15:07
  • 1
    Run `git rm --cached `, where `` stands for the path to the file in question. – jub0bs Jun 17 '15 at 15:07

2 Answers2

4

I faced similar situation. Here is what I followed to make unstaged to untracking.

  1. git rm [FileName and path] --cached

Now corresponding File is deleted. It keeps the file in localhost with --cached option

  1. git commit (the deleted files).

Build your project again. You will get the File in Untracked if it is generated always. Now add it in .git/info/exclude.

  1. git status

You are now untracking the initially unstaged file.

Note: You will not get the files in untracking if they are not generated during build. I mean they are removed from git tracking totally.

rajStack
  • 41
  • 3
2

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.

Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
  • 1
    Firstly, thanks for your reply. I don't want them to really 'move' anywhere, in a storage sense. I just want to reclassify them as 'untracked.' But if that's not easily achieved through the standard array of git commands, I'll just have to try something else. – J.M. Janzen Jun 17 '15 at 17:53