Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git ignore locally deleted folder

Tags:

git

ignore

I have a Ruby on Rails application which crashes when vendor/rails is present but works fine if it is not. I need to keep this folder deleted in my local copy so that I can work, but I don't want this deletion to ever be committed. Someone put it there for a reason.

So how do I delete this folder without it coming up in git status as a thousand deleted files? Obviously .gitignore won't work since you can't ignore files which are already tracked. Neither do any of the solutions listed here (git update-index --assume-unchanged) work.

like image 459
Alexander Ljungberg Avatar asked Jan 03 '11 23:01

Alexander Ljungberg


People also ask

Where do all Ignored files get stored in Git?

All ignored files get stored in a .gitignore file. A .gitignore file is a plain text file that contains a list of all the specified files and folders from the project that Git should ignore and not track.

What happens if I remove a file or directory from Git?

Even though you removed the file or directory with the commands above, Git will still try to track it. Additionally, if you accidentally commit or push that certain file or directory in the future, it will end up in a remote repository again. To avoid that, add the full path to the file/dir in question to the .gitignore file.

How do I ignore local changes in Git?

You can’t push these local changes, and putting these configuration files in the .gitignore file is also a no-go as these files need to be tracked by git. Turns out you can ignore local files using the power of Git! If you navigate to the .git folder, there is a folder in there called info, which should have one file inside called exclude.

How do I exclude a specific folder in a git tree?

You have several options: Leave a dirty (or uncommitted) .gitignore file in your working dir (or apply it automatically using topgit or some other such patch tool). Put the excludes in your $GIT_DIR/info/exclude file, if this is specific to one tree.


1 Answers

 git ls-files --deleted -z | git update-index --assume-unchanged -z --stdin

Note that because this is an index-based operation, you cannot set directories to be ignored – only individual files. If upstream ever adds a file inside those directories, you will have to repeat the fix-up.

like image 174
Aristotle Pagaltzis Avatar answered Sep 23 '22 08:09

Aristotle Pagaltzis