基于github存储库创建基于本地存储库的本地git存储库并保持更新 [英] Create local git repository based on local repository based on github repository and keep it updated

查看:87
本文介绍了基于github存储库创建基于本地存储库的本地git存储库并保持更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些基本的git知识,但我不知道如何实现这一点。

我想克隆(?)github WordPress初学者主题




  • 分叉(请参阅分叉回购 )回购 automattic / _s

  • 在本地克隆该分支,

      git clone / url / my / fork myfork 


  • 将原始回购添加为远程上游

      cd myfork 
    git remote add upstream https://github.com/automattic/_s




从那里开始,使用 git 2.9或更高版本,配置:

  git config --global pull.rebase true 
git config --global rebase.autoStash true

最后,每次你想更新你的分支(你修改你自己版本的原始仓库)时,

  git checkout mybranch 
git fetch upstream
git rebase upstream / master

然后,您可以将更新的分支(测试之后)合并到您的其他仓库 my_t heme1 my_theme2 ,从myfork复制。

  cd my_theme1 
git fetch
git merge origin / mybranch

如果你只想在本地工作,您可以跳过叉步并直接克隆原始仓库。


I have some basic git knowledge but I'm not sure how to accomplish this.

I am trying to clone (?) github WordPress starter theme underscores. The idea is to create a basic framework based (with some modifications) on that repository. Then create other themes with that framework as the base.

So it should look something like:

  1. copy github underscores repository to local

  2. create a local repository my_framework from the underscores one, modifying certain parts of those files always (such as the name) and adding some other files

  3. create new local repositories my_theme1, my_theme2 based on my_framework

The goal is to keep everything updated with any underscores update, while changing and modifying the framework and the themes. Once the content from github is pulled it should keep (or inform) of any updates, but I don't need any change I make locally to go back in the path.

I am not sure which path to follow, and would appreciate any help or pointer.

解决方案

The goal is to keep everything updated with any underscores update, while changing and modifying the framework and the themes

That is called the triangular workflow:

  • fork (see "Fork a Repo") the repo automattic/_s
  • clone that fork locally,

    git clone /url/my/fork myfork
    

  • add as remote upstream the original repo

    cd myfork
    git remote add upstream https://github.com/automattic/_s
    

From there, with git 2.9 or more, configure:

git config --global pull.rebase true
git config --global rebase.autoStash true

Finally, each time you want to update your branches (where you modify your own version of the original repo), do a

git checkout mybranch
git fetch upstream
git rebase upstream/master

Then you can merge that updated branch (after testing it) to your other repos my_theme1, my_theme2, cloned from myfork.

cd my_theme1
git fetch
git merge origin/mybranch

If you want to work locally only, you can skip the fork step and clone directly the original repo.

这篇关于基于github存储库创建基于本地存储库的本地git存储库并保持更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆