Reputation: 43427
I have a private git repo which is similar to a dotfiles repo that I use to track shell history across my servers and machines. I do this to have a permanent record of shell incantations that I can refer back to when I encounter a situation in which I vaguely recall knowing how to do something but don't remember the specific command.
For the past few years I have been manually copying shell history files into this repository of mine, but I have lately come to realize that there should be an easier way to do this. I'm usually pretty good about remembering to preserve the history from an environment before decommissioning it, but the repetitiveness of the process has gotten to be a little grating.
The main limitation is that symlinks are not followed by git. Git will simply record the target location of a symlink if you check in a symlink. What I'd like to do, conceptually, set it up so that it would follow the link: that way, I can simply set up my shell history on on multiple machines, check in the "link" to my shell history files, and then I'd like to be able to simply run git diff
there to view and commit any new changes from that point on, without having to manually enter in the file associations again.
If there isn't an easy way to do this, I was thinking maybe a git hook could help, but I don't really know of any client hooks that can run prior to attempting a commit...
I'd like to also mention one behavior which is interesting, with Git on windows it actually does treat symlinks as copies as far as I know. So this should kind of work out of the box on windows. The question is how to trick Linux/macOS on a per-repo basis to do this.
Upvotes: 3
Views: 147
Reputation: 7622
Just do the symlink into the other way. Link your ~/.bash_history
to your git file.
ln -s repo/bash_history ~/.bash_history
I have a script to link all my dot file to a system https://github.com/utix/dotfiles/blob/master/%2Bbin/doconf
Upvotes: 1