zoukankan      html  css  js  c++  java
  • 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项目在自己本地了

  • 相关阅读:
    k8s采坑记
    [dotnet] 封装一个同时支持密码/安全密钥认证的SFTP下载器,简单易用。
    亲测可用,iptables实现NAT转发。
    【转】干货,Kubernetes中的Source Ip机制。
    k8s实践
    干货!分享一款windows下的磁盘分析神器。
    干货,不小心执行了rm -f,除了跑路,如何恢复?
    Java8函数式编程
    搭建git服务器
    Python3安装
  • 原文地址:https://www.cnblogs.com/eason-d/p/12761340.html
Copyright © 2011-2022 走看看