How to remove from Git a file that was tracked and is now in . gitignore?

Asked

Viewed 93 times

2

I have a file that was tracked by git, but now he’s on the list of .gitignore.

However, this file keeps being displayed on git status when it is changed.

What to do to make the git completely forget about this file?

  • Who negatived could contribute indicating the reason or answering the question?

1 answer

1

If they are correctly in the list of . gitignore, the following commands clear these files/directories.

For security you must confirm first with the -n flag!!

Clear files that are not in index / existing in . gitignore

git clean -n -xf

Se correcto então:

git clean -xf

Delete directories that are not in index / existing in . gitignore

git clean -n -df

Se correcto então:

git clean -df
  • This removes remotely as well?

  • @Pedroferreira, the -n is the dry run?

  • 1

    @Jeffersonquesado excuse the delay but yes, as stated, for safety with -n to make a dry run/get an analysis of what will be removed

  • @Pedroferreira, having the information I am happy, no matter how long it takes

Browser other questions tagged

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