I have a .gitignore file like the following:
.*
!.gitignore
And I would like to version my .git/config
file such that when I do a git pull
my .git/config file updates automatically.
How can I do this?
I tried something like:
.*
!.gitignore
!.git/config
But this didn't work. I know if I create a link (ln -s .git/config configurations/git/config
) I can version it, but I would like a better way to update the original one automatically.
I'm thinking of creating a hard link to it (ln .git/config configurations/git/config configuration/git
), but it doesn't appear to be the best way. Is there a way to avoid this? Will Git work properly when versioning hard links?
Edit: explaining why to do this
The main motivation to do this is that I would like to version the home folder of a user of mine. I will use this versioning to help me on some kind of deploys. I'd like to keep all clones synchronized. Conflicts will appear just if I don't manage the things well, and I'll be taking care of this. Maybe I will be versioning another protected git files too.
You can't 'version' your .git/config file. What you can do is create a .gitconfig in your working directory and commit that. Then after a clone you perform.
cat .gitconfig >> .git/config
Of course, this is fraught with all sorts of potential problems. What if somebody edits .gitconfig
? You'd need to undo .git/config
and then re-append after git pull
. What if .gitconfig
changes on a different branch? You'd need to undo .git/config
and re-append on git checkout <branch>
So, I'm not recommending changing .git/config
; but if you must, you must.
As stated by @Tuxdude it is bad information to share .git/config
itself.
But Git (1.7.10+) now supports config inclusion!
So, for important options you may said place them in file: .git.config/repository.config
and in .git/config
just place link to it like:
[include]
path = ../.git.config/repository.config
I just add such recommendation in readme file for repo. It much easy to just copy/paste many lines and versioning important settings like regular file. It also transfer updates for all users of repo.
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