-1

I would appreciate if you help me in this problem I have with git. I am new with working with that. I need to remove untracked change from git. I have already tried "git checkout ." and " git restore .", but those are not working always. Is there any more reliable way? Any help is appreciated.

This is the untracked file I need to be removed from git:

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        secret1.txt

 test-repo % git restore .
 test-repo % git status
HEAD detached from V2
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        secret1.txt

 test-repo % git checkout .
Updated 0 paths from the index
 test-repo % git status
HEAD detached from V2
Untracked files:
   (use "git add <file>..." to include in what will be committed)
        secret1.txt

nothing added to commit but untracked files present (use "git add" to track)

As you can see secret1.txt is still there!

1

2 Answers 2

2

Git commands:

  • git clean -f (remove all untracked files)
  • git clean -f path/to/file (remove the specific file path/to/file)
Sign up to request clarification or add additional context in comments.

Comments

0

"untracked changes" are by definition files which git knows nothing about. The easiest way to fix this is just to delete the file with rm secret1.txt.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.