$HOME git repo (selectively) to github?
I ke开发者_运维百科ep many files in my home directory under git
. Important dotfiles, my thesis, etc.
I want to push certain files to github, e.g., my emacs
configuration, to share.
Obviously, I don't want to push the entire repo. Are submodules
the way to go?
My first thought is to make a directory ~/github/emacs
, and rsync
selective files here, then add a submodule under that directory, pointing to github, to push.
Is this a good idea, or is there a better way?
(I don't want my local git repo storing all files to get muddled up with this stuff, though.)
I store my dotfiles (and other configuration) on github too. My approach is to have all those files only inside the repo and symlink them into the place using a rake task. This has the advantage that your actual home directory is not inside a git repo and you don't have to deal with submodules everwhere, as this would probably become a mess to maintain (and hinders re-usability of your dotfiles and other stuff). For inspiration, my dotfiles repository can be found here: https://github.com/meineerde/dotfiles
Generally, I would advise you to use more smaller git repos, one for each single project. Also you should try to keep your repository structures (esp. submodules) simple to ease maintenance. Just put your stuff side by side and create a new git repo for each new project.
I would discourage using hardlinks (as proposed by Martinho Fernandes) as the link can easily be broken by certain filesystem operations and it's not really obvious that there are hardlinks.
You could create a directory ~/github/emacs
and place hardlinks for the actual files there.
I don't like using symlinks for my dotfiles git directory, as it's such a pain to keep track of. I've switched over to using an internal .git directory and git alias; here's my writeup on versioning dotfiles with git.
精彩评论