- Version 10.0.1
- Project Flyweb Production
- Section blog
Some files in a repository need to be versioned, but not committed to an upstream repository. This is how to achieve and how to create a Custom Action in Sourcetree for this task
The problem how to manage files like configuration files with github took me quite a while to figure out. It was until I stumbled across a stackoverflow answer where I found out about the
update-index git command.
Some files in a repository change often but are rarely committed. Usually, these are various local configuration files that are edited, but should never be committed upstream. Git lets you ignore those files by assuming they are unchanged. http://stackoverflow.com/a/18277622/1423758
update-index command can be used with the option
--no-assume-unchanged, followed by the path to the file. Once a file is marked unchanged,
git ignores any changes nor will it get committed.
$ git update-index --assume-unchanged path/to/file.txt
$ git update-index --no-assume-unchanged path/to/file.txt
I for myself think it's easier and "saver" to use a GUI for
git rather than the Terminal - for that reason, I prefer the app Sourcetree. Sourcetree provides the ability to define "Custom Actions", which can later be easily reused with right-clicking a file or folder.
Open the settings from Sourcetree and choose "Custom Action", now add a new command like in the Screenshot below:
List "assumed unchanged" Files
It can be helpful to see a list of all files which have been set "assumed unchanged". Use the command
git ls-files -v in your Terminal for files that are marked as "assume unchanged".
- git docs: git update-index
- git docs: git ls-files
- github Help Article: "Remove Sensitive Data"
- stackoverflow.com: How do I stop Git from tracking any changes to a file from this commit forward?