https://github.com/marbu/dogit/blob/master/README.md
That said, I'm not sure if it would be direclty usable for anyone other that me in it's current state. It's tailored to my use case and there are few not so well solved use cases.
Few additional advantages of this approach in general:
You can use local branch which is private to the machine and a public branch, Whatewer you commit ends up in the local private branch and if you would like to share it, you need to cherry pick particular commit and rebase (so that you I don't end up sharing private ssh key on github).
You can use any git tool directly on your dotfiles.
One can directly add vim submodules into the dotfiles repo.
Thank you for this.
Since there is interest, I'll elaborate on the understated "a bit painful" part of moving the files after an initial clone which leaves the files in the ~/dotfiles dir. The problem is that I didn't find an easy "move and overwrite recursively" command in Linux.
Here's the magic command from my script: git ls-files --cached -z | rsync -av --from0 --remove-source-files --files-from - ${dir} ~/ && find . -type d -empty -delete
To spell it out, it's having git list all the files in the repo (so skipping any unversioned files such as the .git dir itself), using the NUL byte as file termination to avoid any (most?) special character issues in file names, and using rsync to move the files over thanks to --remove-source-files. However rsync doesn't remove empty directories (durr), so have the find do that.
Also, you probably want to set "git config status.showUntrackedFiles no" ;)
$ git clone --bare [email protected]:mbudde/homedir.git .homegit
$ git --git-dir=.homegit --work-tree=~ checkout -f # Overwrite existing files
$ echo '*' >> .homegit/info/exclude
And then I have a simple git wrapper script [1]. I moved from using an alias to a script for some reason I can't remember (and of cause I didn't write it in the commit message -_-).[1] https://github.com/mbudde/homedir/blob/master/usr/bin/hgit
You don't need recursiveness into commands, just use find (maybe with xargs) to generate the list of files to overwrite (or commands to execute).
No wait, I mean find is a really powerful and sophisticated tool, but it takes time and effort to get it to do precisely what you want. It turned out rsync did what I wanted more easily.
I keep my dotfiles in a sub-directory (doesn't matter where) and use the following Rakefile to manage it:
https://github.com/tvon/dotfiles/blob/master/Rakefile
Then it's just `rake status` or `rake link` to symlink everything. I've only been using this for a few years but I haven't run into any problems yet.
I also make an effort to push my config files into .config wherever possible. I really hate the ~ dotfile clutter.
1. There could be many "hg-dirs" for a one regular "workdir" (e.g. .hg_foo, .hg_bar, .hg_baz, ...)
2. There'd be a wrapper tool, that on any hg command would autodetect to which hg-dir any given affected file belongs, if already committed earlier (with ability to override the autodetection by hand, including for adding brand new files to the repo).
However, didn't care enough to try implementing this yet. Also, not quite sure how/whether it could work with git, given the existence of staging area.
(full story: http://stackoverflow.com/a/5789827/98528)
It works really well for me.
git clean -dfx git() {
local toplevel=$(command git rev-parse --show-toplevel 2>/dev/null)
if [[ "${toplevel}" == "${HOME}" ]] && [[ "$1" == "clean" ]]; then
>&2 echo "Do NOT run git clean in this repository."
return
fi
command git "$@"
}
Right. Which is why I use git with a workspace detached from the git directory. The git directory is in ~/dotfiles/.git, with "git config core.worktree ~", and I set an alias "dgit=git --git-dir ~/dotfiles/.git". The advantage of this method is that there are no symlinks to maintain, however initial clone is a bit painful, since you have to move the files and set the config.
It's not perfectly straightforward, but it's as close to it as I could get it.