Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git remove new untracked files [duplicate]

Tags:

git

git-branch

this should be simple but i cant find the right anwer I am new to git I added a bunch of new files (not staged) to my git tree i want to just delete them without also deleting the git ignore files in that directory any commands? the

git clean -nd

command tells me it will erase all my .git ignore files as well?

like image 280
Yehuda Schwartz Avatar asked Nov 24 '15 14:11

Yehuda Schwartz


1 Answers

For your case, you could give an exclude parameter:

git clean -nd -e **/.gitignore

However, normally, I think it would be recommended to do either of these instead:

  • Commit your .gitignore file. If the ignore rules are useful for everyone who uses the repo, then it makes sense to push it to the remote. git clean will not remove committed files.
  • If you have personal ignore rules, put them in the .git/info/exclude file instead of a .gitignore file. (This is a recommendation from gitignore documentation)
like image 72
Alderath Avatar answered Oct 21 '22 01:10

Alderath