简体   繁体   English

$ HOME git repo(有选择地)到github?

[英]$HOME git repo (selectively) to github?

I keep many files in my home directory under git . 我在git下的主目录中保存了很多文件。 Important dotfiles, my thesis, etc. 重要的dotfiles,我的论文等

I want to push certain files to github , eg, my emacs configuration, to share. 我想将某些文件推送到github ,例如我的emacs配置,以便共享。

Obviously, I don't want to push the entire repo. 显然,我不想推动整个回购。 Are submodules the way to go? submodules是否submodules

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. 我的第一个想法是在这里创建一个目录~/github/emacsrsync选择性文件,然后在该目录下添加一个指向github的子模块来推送。

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.) (但我不希望我的本地git repo存储所有文件,但是这些内容会变得混乱。)

I store my dotfiles (and other configuration) on github too. 我也将我的dotfiles(和其他配置)存储在github上。 My approach is to have all those files only inside the repo and symlink them into the place using a rake task. 我的方法是将所有这些文件只放在repo中,并使用rake任务将它们符号链接到该位置。 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). 这样做的好处是你的实际主目录不在git repo中,你不必处理任何地方的子模块,因为这可能会变得很难维护(并且阻碍了你的dotfiles和其他东西的可重用性)。 For inspiration, my dotfiles repository can be found here: https://github.com/meineerde/dotfiles 为了获得灵感,我的dotfiles存储库可以在这里找到: https//github.com/meineerde/dotfiles

Generally, I would advise you to use more smaller git repos, one for each single project. 一般来说,我建议你使用更小的git repos,每个项目一个。 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. 只需将您的东西并排放置,为每个新项目创建一个新的git仓库。

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. 我不鼓励使用硬链接(由Martinho Fernandes提出),因为某些文件系统操作很容易破坏链接,并且存在硬链接并不是很明显。

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

I don't like using symlinks for my dotfiles git directory, as it's such a pain to keep track of. 我不喜欢在我的dotfiles git目录中使用符号链接,因为跟踪它是一件很痛苦的事情。 I've switched over to using an internal .git directory and git alias; 我已经切换到使用内部.git目录和git别名; here's my writeup on versioning dotfiles with git . 这是我用git编写版本的dotfiles的文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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