简体   繁体   中英

$HOME git repo (selectively) to github?

I keep many files in my home directory under git . Important dotfiles, my thesis, etc.

I want to push certain files to github , eg, 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.

你可以创建一个目录~/github/emacs并为那里的实际文件放置硬链接

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM