I have a .htaccess file with specific settings inside it that only work for my machine.
When I pull in changes from another persons branch I always have to undo the changes made.
I think I can do git checkout file hash to get the original file back (is that correct? If not can someone show me the correct command) but is there not a way I can tell Git to track the file on my branches but to never pull down the file from another remote branch?
On a similar note: how can you have git track a particular file but never push it to a remote branch. Eg I have a file with password details inside it but if I’m storing my file publicly on GitHub then I don’t want that file pushed up.
Thanks
The command to restore the file to what it had been in a previous version is actually
With the arguments in the opposite order of what was in the question. The commit can either be a hash or any other way of referring to a commit such as a branch or tag name.
You could setup git to automatically keep your version of the
.htaccessfile by specifying a custom merge driver.To do this, first you’d need to define the merge driver in the git config, and then specify that that merge file should be used for the
.htaccessfile.But, this would not be a good idea if your local branch will ever be merged into the branch from which you’re pulling changes. This would be recording that changes to that file have been merged even though they’re actually being completely ignored. So if your branch were merged back into the other branch all changes to that file would likely be reverted.