gitlab fork项目更新操作说明

需求

在开发项目中,需要在基础框架代码上进行开发,但又想能及时更新基础框架代码的新功能,所以就有fork 项目, update 远程仓库代码的操作需求。

操作过程

fork项目

在操作项目时,先fork一个基础项目,在以inmansoft-backend项目为例

更新源项目代码

当源项目代码有更新时,我们可以通过remote的方式去获取更新

更新步骤

主要的操作命令:

  1. 查看目前仓库可以远程更新的信息
    git remote -v
  2. 配置一个远程更新链接,要拥有git仓库访问权限的
    git remote add upstream git@github.com:xxx/xxx.git
  3. 拉取远程仓库的代码
    git fetch upstream
  4. 合并远程仓库的代码
    git merge upstream/master
  5. 把远程仓库的代码作为新源提交到自己的服务器仓库中
    git push

操作实例

  1. 查看目前仓库可以远程更新的信息
$ git remote -v
origin  http://username:password@htwy:8088/jenkins/inmansoft-backend.git (fetch)
origin  http://username:password@htwy:8088/jenkins/inmansoft-backend.git (push)
  1. 配置一个远程更新链接,要拥有git仓库访问权限的
$ git remote add fetch-stream http://username:password@htyw:8088/backend/inmansoft-backend.git

$ git remote -v
fetch-stream    http://username:password@htyw:8088/backend/inmansoft-backend.git (fetch)
fetch-stream    http://username:password@htyw:8088/backend/inmansoft-backend.git (push)
origin  http://username:password@htwy:8088/jenkins/inmansoft-backend.git (fetch)
origin  http://username:password@htwy:8088/jenkins/inmansoft-backend.git (push)
  1. 拉取远程仓库的代码
$ git fetch fetch-stream
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 12 (delta 6), reused 0 (delta 0)
Unpacking objects: 100% (12/12), done.
From http://htwy:8088/backend/inmansoft-backend
 * [new branch]      master          -> fetch-stream/master
  1. 合并远程仓库的代码
$ git merge fetch-stream/master
Updating 0386ba6..7778790
Fast-forward
 src/main/resources/application.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  1. 把远程仓库的代码作为新源提交到自己的服务器仓库中
$ git push
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (12/12), 1.09 KiB | 223.00 KiB/s, done.
Total 12 (delta 6), reused 0 (delta 0)
To http://htwy:8088/jenkins/inmansoft-backend.git
   0386ba6..7778790  master -> master

图例

fork项目

原始项目 backend/inmansoft-backend


image.png

fork出来项目 jenkins/inmansoft-backend


image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1,查看所有远程分支:%git branch -r 2, 拉取远程分支并创建本地分支git checkout -...
    will666阅读 2,092评论 0 18
  • Git 基础 基本原理 客户端并不是只提取最新版本的文件快照,而是把代码仓库完整的镜像下来。这样一来,任何一处协同...
    __silhouette阅读 15,947评论 5 147
  • 配置 首先是配置帐号信息 ssh -T git@github.com#登陆github 修改项目中的个人信息 1 ...
    rochuan阅读 751评论 1 1
  • 我还没有完成毕业实习报告也还没开始初级的复习。我想我之前一直都处于失败状态是因为自己总想不劳而获吧!只有清楚的意...
    缘心初现阅读 250评论 0 0
  • 魏春英/文 今日我的拙作《腊月十五夜》赏月(诗五首)在滑台文学发表,遂发朋友圈表达喜悦之情,恩师丁学师先生赋诗以示...
    风儿朵朵阅读 720评论 0 11