How do I remove local files(untracked files) from my current branch(branch) in Git?

Asked

Viewed 15,428 times

6

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

4 answers

5


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

git rm <file>

Running the command below checks that the file is marked as Deleted:

git status

Now just effect the removal by committing:

git commit -am "Removido arquivo..."
  • @Walter, have you ever asked this question here? If not... create one, so we don’t mix within the question asked above!

5

If the files are in the state Untracked means that the git not yet have they under versioning.

You can use the following command:

git clean -f

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

It is worth noting that after deleted you will not have to reverse, after all the file never was under versioning.

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

1

You can consult the documentation on https://git-scm.com/docs/git-rm

git rm arquivo.txt

after this just give a commit to confirm the removal

git commit -a -m "Exclusao do arquivo.txt"

1

Shows the files that will be removed:

git clean -dnf

Removes the untracked files

git clean -df

Browser other questions tagged

You are not signed in. Login or sign up in order to post.