• Git fork代码同步更新


    背景: 在Gitee看到某个非常棒的项目, Fork到自己仓库, 同时git clone 自己仓库,用来自己开发,  后来初始Fork的项目更新了, 于是想更新初始Fork的最新代码和已改的代码整合起来..

    首先在本地查看remote源, 可以看见初始本地仓库副本的2个源

    PS E:workspace_ideaRuoYi-Vue> git remote -v
    origin  https://gitee.com/easonstudy/RuoYi-Vue.git (fetch)
    origin  https://gitee.com/easonstudy/RuoYi-Vue.git (push)

    此时新增原始Fork项目源, 然后再查看remote源

    PS E:workspace_ideaRuoYi-Vue> git remote add upstream https://gitee.com/y_project/RuoYi-Vue.git
    PS E:workspace_ideaRuoYi-Vue> git remote -v
    origin https://gitee.com/easonstudy/RuoYi-Vue.git (fetch)
    origin https://gitee.com/easonstudy/RuoYi-Vue.git (push)
    upstream https://gitee.com/y_project/RuoYi-Vue.git (fetch)
    upstream https://gitee.com/y_project/RuoYi-Vue.git (push)

    然后拉取upstream(Fork)代码,本地会有upstream/master分支

    PS E:workspace_ideaRuoYi-Vue> git fetch upstream
    From https://gitee.com/y_project/RuoYi-Vue
    * [new branch] master -> upstream/master

    切换到自己仓库master分支,并合并upstream/master

    PS E:workspace_ideaRuoYi-Vue> git branch
    * master
    PS E:workspace_ideaRuoYi-Vue> git checkout master
    Already on 'master'
    Your branch is ahead of 'origin/master' by 1 commit.
      (use "git push" to publish your local commits)
    PS E:workspace_ideaRuoYi-Vue> git merge upstream/master
    Already up to date.

    更新完后实现自己仓库和Fork项目在自己本地了

  • 相关阅读:
    HDU 1261 字串数(排列组合)
    Codeforces 488C Fight the Monster
    HDU 1237 简单计算器
    POJ 2240 Arbitrage
    POJ 3660 Cow Contest
    POJ 1052 MPI Maelstrom
    POJ 3259 Wormholes
    POJ 3268 Silver Cow Party
    Codesforces 485D Maximum Value
    POJ 2253 Frogger(最短路)
  • 原文地址:https://www.cnblogs.com/eason-d/p/12761340.html
Copyright © 2020-2023  润新知