how to remove untrack changes but keeping indexed changes

45 Views Asked by At

in my git status I see this

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

modified: file1
modified: file2
modified: file4

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

modified: file1
modified: file4

how can I reset the files to the current staged changes and discarding only the non-staged changes.

1

There are 1 best solutions below

2
On BEST ANSWER

You can do it using checkout command, just like that:

git checkout file1
git checkout file4

Hope this help