Heres my latest headscratcher:
I commit my global git configuration ~/.gitconfig
into a dotfiles repo. My actual repo is named vim-config
, and I reckon it can continue being named as such because the .vimrc
is by far the centerpiece of this repository.
At any rate, the point is that when I set up a new dev environment for myself I will do something not unlike this:
git clone git@github.com:unphased/vim-config ~/.vim
ln -s ~/.vim/.gitconfig .gitconfig
I can pretty much start using git from my new environment just fine.
But now I want to add a nice new thing -- I want to change my name for each of my devices so that from now on, when I look in my git commit logs, I want to be able to tell that I made some commit from my MacBook, or from my iPhone, or from my CentOS 7 VM I kickstarted in the middle of January or from the Centos 6.4 VM from a while back, or even if i made the commit while SSHd to my MacBook from my Windows 7 desktop, or, heck, I'm gonna go all-out... to tag commits with lat/long coordinates. All in the desperate pursuit of adding information that might in any way help me remember what the hell I was doing when I look up code from months in the future.
The last ones there have separate challenges that I'll figure out later (to see if I can make my git name string conditional based on an environment variable i can easily call git config
etc. and script this with my shell login configs), but there is a bigger problem that's standing in the way of my differentiating these configurations.
It requires me to make a branch for each of my environments, making it so that I can't actually make changes in my repository without swapping branches twice, and possibly doing a git merge every time. I have to make a branch macbook
and in this branch change my name in my .gitconfig
to Steven Lu [rMBP]
and so on.
The point is that I must leave each of my environments checked out into their own respective branches in order to have them keep unique names.
And since I do not want to branch out the rest of the actual content in my repository, I have to constantly do git merges. I'm thinking about it and it's not necessary to merge changes back to master and merge them back out to everyone else, but it still requires merging (instead of a carefree alias gl="git pull"
) pretty much every time.
So the question is... does git provide some method of temporarily overriding the global configuration? It's reasonable that this can be done on a per-cloned-repository basis, but that's not satisfactory, that's way too much bookkeeping to make it worthwhile. So I need some sort of separate but still global git setting override.
I know of more potential solutions. There is a way to tell git to ignore the changes made to a file that is checked in. git update-index --assume-unchanged
. This just might work. What I dont like about it is that I have to remember to be extra careful about editing my git configuration any further, because git's just going to ignore changes made. But this does allow me to not have to make new branches and do any of the merging nonsense.
So..... is there another option out there?