Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull but never push file

Tags:

git

I couldn't find anything specific to this but if I missed it please let me know.

I have a file in git which needs to be there. Once pulled down each individual will need to edit it to add their own credentials to it. When edited by the individual I do not want it to show up as having been changed or anything because we want to keep the generic file without credentials in our repo. Is there an option to have a file set up as "Pull this file but never push it"? Currently the setup we have is the file is named Upload.bat_COPY_EDIT_RENAME, which hopefully makes it obvious what to do, and I have Upload.bat in the .gitignore. I'd like something more idiot proof.

I know there are options like --assume-unchanged but I don't want to have to run that every time and it seems kind of like a bandaid fix which could potentially cause problems later.

Thanks for your help!

like image 488
GRobb Avatar asked Feb 19 '16 19:02

GRobb


Video Answer


1 Answers

I would suggest a slightly different approach... You can write your Upload.bat to read from a settings file using your format of choice. Say you call it, secrets.txt. Then you can add secrets.txt to your .gitignore and commit Upload.bat with impunity. When users pull the repo, they will get Upload.bat and can create their own secrets.txt.

You might make secrets.txt have just the username and password, separated by a newline. Should be trivial to parse this way.

like image 185
Kevin Burdett Avatar answered Sep 24 '22 17:09

Kevin Burdett