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?
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With