xX4m4zingXx xX4m4zingXx - 1 month ago 5x
Git Question

Only push certain files once

I have a git repository for a server.
That server needs some files, but these files only have to be pushed once.
So when someone edits it, then it doesn't have to be pushed to github, but when someone downloads the repository they should get the unedited file.

The server needs these files to run, but for every person are these files different, that's why I don't want it to be pushed again.

How can I do this?


If you haven't committed the files yet, i'd say add the filename to your .gitignore file like:


So in case the file is package.json:


Wildcards can be made by using the *


or as AoeAoe remarked: you can add the file later using git add --force to overrule the .gitignore file.

Now if the content of your file is merely 10 rules of config, i'd say: create a mock-up out of it and write it down in your readme.md and instruct your colleagues to create their own, otherwise, you should follow the advice in the update section.

Update: as Edward Thompson stated: .gitignore doesn't apply to uploaded files you'll be forced to use git update-index

To force the file from not updating:

git update-index --assume-unchanged path/to/file

To enable updating again:

git update-index --no-assume-unchanged path/to/file