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:
<filename>.<extension>
So in case the file is package.json:
package.json
Wildcards can be made by using the *
*.json
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
These files changes should be ignored by git remote repository, since they need a local management. You have to add the path of these files to .gitignore file. If you have already committed and pushed original version of your files, when someone clones the repository, it will receive the original files without any local changes.
How to add gitignore file
How to ignore certain files
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