I have several files in a CodeIgniter site that I will want to have in the repo but not track any changes on.
For example, I deploy a new installation of this framework to a new client, I want the following files to be downloaded (they have default values CHANGEME) and I just have to make changes specific to this client (database credentials, email address info, custom CSS).
// the production config files i want the files but they need to be updated to specific client needs application/config/production/config.php application/config/production/database.php application/config/production/tank_auth.php // index page, defines the environment (production|development) /index.php // all of the css/js cache (keep the folder but not the contents) /assets/cache/* // production user based styling (color, fonts etc) needs to be updated specific to client needs /assets/frontend/css/user/frontend-user.css
Currently if I run
git clone [email protected]:user123/myRepo.git httpdocs
and then edit the files above, all is great. Until I release a hotfix or patch and run git pull
. All of my changes are then overwritten.
For files that aren't tracked by Git, you can use a . gitignore or exclude file. For files that are tracked by Git, you can tell Git to stop tracking them and to ignore changes.
You have to add the untracked files of the repository by using the “git add” command and run the “git stash” command to save the untracked file and clean the current directory for working by removing the untracked file from the repository folder.
git has a different solution to do this. First change the file you do not want to be tracked and use the following command:
git update-index --assume-unchanged FILE_NAME
and if you want to track the changes again use this command:
git update-index --no-assume-unchanged FILE_NAME
git-update-index documentation
To pull an answer out of the comments of another answer:
$ git update-index --skip-worktree FILENAME
Appears to be a better option than --assume-unchanged
More can be read about this here: Git - Difference Between 'assume-unchanged' and 'skip-worktree'
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