$HOME git repo (选择性地)到 github?
我在 git
下的主目录中保存了许多文件。重要的点文件、我的论文等。
我想将某些文件推送到github,例如我的emacs
配置,以进行共享。
显然,我不想推送整个存储库。子模块是正确的选择吗?
我的第一个想法是创建一个目录~/github/emacs
,并在此处选择rsync
文件,然后在该目录下添加一个子模块,指向github,进行推送。
这是一个好主意,还是有更好的方法?
(不过,我不希望存储所有文件的本地 git 存储库与这些内容混淆。)
I keep 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.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也将我的点文件(和其他配置)存储在 github 上。我的方法是仅将所有这些文件放在存储库中,并使用 rake 任务将它们符号链接到该位置。这样做的优点是,您的实际主目录不在 git 存储库内,并且您不必在任何地方处理子模块,因为这可能会导致维护混乱(并阻碍点文件和其他内容的可重用性)。为了获得灵感,我的 dotfiles 存储库可以在这里找到:https://github.com/meineerde/dotfiles
,我建议您使用更小的 git 存储库,每个项目一个。此外,您应该尝试保持存储库结构(尤其是子模块)简单以方便维护。只需将你的东西并排放置,并为每个新项目创建一个新的 git 存储库。
我不鼓励使用硬链接(如 Martinho Fernandes 提议的),因为链接很容易被某些文件系统操作破坏,而且硬链接的存在并不明显。
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
并放置 实际文件的硬链接。You could create a directory
~/github/emacs
and place hardlinks for the actual files there.我不喜欢在我的 dotfiles git 目录中使用符号链接,因为跟踪起来很麻烦。我已改用内部 .git 目录和 git 别名;这是我关于使用 git 对点文件进行版本控制的文章。
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.