简体   繁体   English

如何维护一个存储库的多个分支?

[英]How to maintain multiple branches of a repository?

I use a repository on github.com to maintain my personal configuration of the FAR Manager , an orthodox file manager. 我使用github.com上的存储库来维护FAR Manager (正统文件管理 )的个人配置。 I use it on my home computer and on the work laptop. 我在家用计算机和办公笔记本电脑上使用它。 Their FAR Manager configurations (profiles) differ slightly because of other programs' paths, drive names, folder shortcuts, etc. but they share a great deal. 由于其他程序的路径,驱动器名称,文件夹快捷方式等,它们的FAR Manager配置(配置文件)略有不同,但是它们共享很多。 From time to time I install a plugin or find a configuration which I'd like to share globally across profiles. 我会不时安装插件或找到要在配置文件中全局共享的配置。

Basically everything specific to my home or work configuration is in the /MyProfile/Home subfolder or /MyProfile/Work subfolder respectively. 基本上,特定于我的家庭或工作配置的所有内容都分别位于/MyProfile/Home子文件夹或/MyProfile/Work子文件夹中。

I don't know exactly what would be the best practice about backing-up all my computers' local configurations at the remote master repository on github.com. 我不知道在github.com上的远程主存储库中备份所有计算机的本地配置的最佳实践是什么。

I think maybe I want to maintain two branches of this repository on github.com for a long term. 我认为也许我想长期在github.com上维护此存储库的两个分支。 A branch Home and another branch Work whereto I would push the current configuration from my home or work computer respectively. 分支Home和另一个分支Work向其中我会从我的家庭或工作计算机分别按当前的配置。 But if there is better ways to do it, I welcome any suggestions. 但是,如果有更好的方法,我欢迎提出任何建议。

So far, at my home computer, I cloned the remote master repository and then I created a branch home 到目前为止,在我家的电脑,我克隆远程master仓库,然后我创建了一个分支home

git clone <github url>
git branch home
git checkout home
git push --set-upstream origin home

and at my work laptop I cloned the master repository and then I created a branch work 然后在我的工作笔记本电脑上克隆了master存储库,然后创建了一个分支work

git clone <github url>
git branch work
git checkout work
git push --set-upstream origin work

But now I don't know anymore how to push the commits. 但是现在我不知道如何推送提交了。 Would a simple git push be enough or do I need to do things differently? 一个简单的git push就足够了吗,还是我需要做一些不同的事情?

Having separate branches for home and work would be fine as long as you will start creating additional branches , for any future update, from these and not from master. 只要您将开始从这些主目录而不是从主目录创建其他分支,以便将来进行任何更新,就可以为家庭和工作使用单独的分支。 In other words you will end up having a master branch for home and another master branch for work. 换句话说,您最终将拥有一个用于家庭的主分支和另一个用于工作的主分支。 Any push should be made to children branches of these ones. 应该对这些分支的子分支进行任何推动。 And PRs should be made against one of these branches (work or home). 并且应该针对这些分支机构之一(工作或家庭)进行PR。

Alternatively, you could consider to have a single master Branch and having just two folders home and work. 另外,您可以考虑拥有一个主分支,只有两个文件夹可以正常工作。 Mostly would depend on your setup. 通常取决于您的设置。

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

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