2

I have some questions about undo git add and git reset.

Recently I made some mistakes.
First, I added all directory's files. And I want to cancel added. Then, some of the directories are removed after I wrote a git rm- command.
Second, Still, several Untracked Files are maintained. And I found solutions. And I did git reset. but, it's still maintained.

In colclusion, I could't recover some of the directories and so many Untracked Files are maintained to Untracked Files status.

How can I solve this problem?
At least, I hope to cancel Untracked Files.

Untracked files status it's my Untracked files status

Momin
  • 3,200
  • 3
  • 30
  • 48
김준태
  • 33
  • 4

1 Answers1

1

Use git clean for that.

-n will show that will be deleted

git clean -n

now delete files:

git clean -f

To remove directories, run git clean -f -d or git clean -fd

To remove ignored files, run git clean -f -X or git clean -fX

To remove ignored and non-ignored files, run git clean -f -x or git clean -fx

orvi
  • 3,142
  • 1
  • 23
  • 36
  • Thanks orvi! and i read your answer. Then, i have another question to yours. if i command "git clean", real file or directory in my computer is removed or just removed in github command part? – 김준태 May 08 '17 at 06:14
  • And add some question. if i command "git clean", real file or directory in my computer is removed or just removed in github command part? – 김준태 May 09 '17 at 05:51
  • `git clean` Cleans the working tree by recursively removing files that are not under version control means it will clear your working directories from your local direcotires. – orvi May 09 '17 at 05:59
  • Actually, i already removed some directories in my local. Then, i could't recover. In this case, can you give me another way to cancel "git add" do not remove something? – 김준태 May 12 '17 at 17:01