Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git ignore deleted files

I have a website project that has more than 50,000 unimportant files (to development) in some directories.

/website.com/files/1.txt
/website.com/files/2.txt
/website.com/files/3.txt
/website.com/files/etc.txt

The stuff in /files is already in the repo. I want to delete all the files in /files on my local copy but I want git to ignore it so it doesn't delete them when I do a pull on the web server.

Any ideas?

like image 678
Petah Avatar asked Apr 27 '10 02:04

Petah


People also ask

Does git ignore delete files?

gitignore will prevent untracked files from being added (without an add -f ) to the set of files tracked by Git. However, Git will continue to track any files that are already being tracked. The removal of the file from the head revision will happen on the next commit.

How do I ignore unwanted files in git?

To avoid having to ignore unwanted files manually, you can create a . gitignore file in the working directory of your project. Inside this file, you can specify simple patterns that Git will use to determine whether or not a file should be ignored.

How do I ignore files in a folder in git?

Personal Ignore Rules Patterns that are specific to your local repository and should not be distributed to other repositories should be set in the . git/info/exclude file. For example, you can use this file to ignore generated files from your personal project tools.

What happens to deleted files in git?

Git keeps a log of all the changes made to files within a repository. You can restore a file that you have deleted since a previous commit by using the git checkout command. This command lets you navigate to a previous point in your repository's history.


1 Answers

Ignoring a whole directory didn't work. I had to do this:

for i in `git status | grep deleted | awk '{print $3}'`; do git update-index --assume-unchanged $i; done
like image 105
dave1010 Avatar answered Sep 21 '22 14:09

dave1010