Afaik, typically there're two ways of doing this: a) symbolic link b) syncing script. In both case, you have to create another repo (name it
dotfile below) for
bash_profile to be version controlled.
Use symbolic links
bash_profile gets moved to your version controlled dir(containing
$HOME/.bash_profile is a soft link ⇢
$HOME/dotfile/bash_profile is where your actual
bash_profile resides, see holman dotfile as an example.
Use syncing script
bash_profile stays in your
HOME dir but it's only a copy of the 'latest' one . The latest
bash_profile still lives in
Yep, it's a copy and paste approach, this is why you need some
syncing scriptto save you from DRY work. see mathiasbynens dotfiles as an good example. His
syncing script https://github.com/mathiasbynens/dotfiles/blob/master/bootstrap.sh.
As you suspect:
I'm curious if there's a good way to version control a single file in a populated directory
Version controlling a single file doesn't make much sense, copy & paste or just drop it into some cloud drives saves you much hassle.
The real point is that things don't get scaled this way, when the
dotfiles in your
$HOME grows, when you want to version control your favorite text editor's config(say
vimrc), when you use
SSH to work with multiple shell remotely, you might have
This means in the long run you might want to version control all your
dotfiles. Github's dotfile is a good starting point.