I have a "parameters" file in a repo, which I've added to .gitignore
so it is not being tracked.
I need to push it once so that it shows in the repo, but making sure it is not tracked. This is because I'll keep modifying it (since it stores input parameters) and I only want the default version showing in the repo.
If I git add --force my_params.dat
the file is pushed, but then it keeps being tracked, which I do not want.
What are the correct steps to achieve this? I tend to avoid using git update-index --assume-unchanged FILE_NAME
because I feel it obscures the tracking process, but I'm not strictly opposed to using it.
If I had to use the answers in the question How to make Git "forget" about a file that was tracked but is now in .gitignore?, I'd need to:
remove parameters file from .gitignore
push file and changed .gitignore
re-add parameters file to .gitignore
and push
remove all tracked files with git rm --cached -r .
re-add all files with git add .
and push them
This doesn't work because it deletes the parameters file from the repo when I push . That's not what I need.
I don't think it is intended nor possible via git.
I would recommend to hierarchically load the paraemter files. You either load parameters.file
or, if not existing, paramters.default.file
. The paramters.default.file
is kept in git, whereas the parameters.file
is ignored.
Users who want to adapt the parameters need to create a file parameters.file
for that purpose (alternatively you can automate the process during some make/setup process).
It looks like there's been a new feature added to support this kind of scenario
git update-index --skip-worktree <file>
Source: https://stackoverflow.com/a/20241145/2436737
More info: 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