How to remove untracked files from my current branch in Git?

5

How to remove these files from my current branch in Git?

    
asked by anonymous 05.05.2015 / 19:56

4 answers

6

You need to mark a file for deletion with the command below

git rm <file>

Executing the command below, the file is marked deleted :

git status

Now you can only perform the removal by doing the commit:

git commit -am "Removido arquivo..."
    
06.05.2015 / 06:27
4

If the files are in the Untracked state, it means that git does not yet have them under versioning.

You can use the following command:

git clean -f

Or delete the files manually with your preferred program, for example command rm on the command line.

It is worth mentioning that after deleting it will not be able to revert, after all the file never was under versioning.

If the files are versioned in git then the correct answer is @ Brandão

    
06.05.2015 / 09:51
1

Shows the files that will be removed:

git clean -dnf

Remove untrackeds files

git clean -df
    
30.05.2016 / 23:30
1

You can consult the documentation at link

git rm arquivo.txt

After this, simply commit to confirm the removal

git commit -a -m "Exclusao do arquivo.txt"
    
12.03.2017 / 14:06