git fork 项目的更新

fork:github网站的操作,将开源项目复制一份到自己的仓库中

那fork的项目在原仓库更新后,如何同步呢?

1.查看远程仓库

$ git remote -v
origin  https://code.xxx.com/beibei/yyy.git (fetch)
origin  https://code.xxx.com/beibei/yyy.git (push)

2.添加当前folk的仓库的原仓库地址

$ git remote add upstream https://code.xxx.com/ABC/yyy.git

查看是否添加成功

$ git remote -v
origin  https://code.xxx.com/beibei/yyy.git (fetch)
origin  https://code.xxx.com/beibei/yyy.git (push)
upstream        https://code.xxx.com/ABC/yyy.git (fetch)
upstream        https://code.xxx.com/ABC/yyy.git (push)

3.获取原仓库的更新

git fetch upstream

4.查看本地分支

$ git branch -a
  persist
* release
  remotes/origin/HEAD -> origin/persist
  remotes/origin/persist
  remotes/origin/release
  remotes/upstream/persist
  remotes/upstream/release

5.同步更新内容到本地对应分支

git merge upstream/release

6.查看原仓库的更新

git log

7.提交更新内容到 fork 地址

git push origin release

 

posted @ 2022-08-06 23:21  慕尘  阅读(823)  评论(0编辑  收藏  举报