Git pull ignore one file in local directory

I kept git on bitbucket and worked from multiple locations (work / home desktop / laptop / 2 servers). I always push on the remote and pull from other cars. Problem - only one machine has a file that I don't want to be pulled / loaded from git every time. What can be done?


source to share

2 answers

It's impossible. git requires an exact copy of the repository to work properly. All git objects (files, directory trees, commits ...) compute the checksum of the object. This is used to create identifiers and further ensure the integrity of the repository. Therefore, ignoring one file will create a completely new repository.



It's pretty hacky, but theoretically possible with git hooks .

Within the .git

project folder , you can define scripts that will run at different points in the git stream.

On that particular computer, script on pull will remove the file immediately after the pull. Another script will check the file right before pushing so that it doesn't commit the file being deleted.

Finally, you can tell git on this machine to ignore the fact that this file is missing using the git assume-unchanged




All Articles