4

In order to include some untracked files in my commit I followed this post and accidently added a lot of unwanted stuff. Now I have this situation in my repo.

2016-02-02 16:51 Unknown            o Staged changes <--- untracked files
2016-02-02 16:51 Unknown            o Unstaged changes <-- want to preserve
2016-01-04 17:01 XXXXX YYYYY        I [wool_task_conversion] [master] [origin/HEAD] [origin/master] First commit

I now want to bring back the untracked files in thier original position i.e. the unstaged area as before preserving the changes in unstaged area for tracked files.

Community
  • 1
  • 1
Black_Zero
  • 345
  • 1
  • 4
  • 11

2 Answers2

4

If you look at the output of git status it actually answers this question:

Davids-Mac-Pro:DAD dhoelzer$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   t

So, simply executing git reset HEAD <file> will do what you are asking.

If you want to remove all staged changes while retaining the changes, the following should be correct:

 git reset HEAD -- .

This should be run from the root of your project.

David Hoelzer
  • 14,530
  • 4
  • 39
  • 61
0

Use,

git reset or git reset --mixed

--mixed

Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.

You can then accordingly stage the required files.

pratZ
  • 2,650
  • 1
  • 14
  • 26