当前位置:   article > 正文

github同步fork仓库与原作者仓库_github代码被fork了但是不知道谁fork的

github代码被fork了但是不知道谁fork的

github同步fork仓库与原作者仓库

1. 查看远程仓库

$ git remote -v
# List the current remotes
origin  https://github.com/user/repo.git (fetch)
origin  https://github.com/user/repo.git (push)
  • 1
  • 2
  • 3
  • 4

2. 添加远程上游仓库

$ git remote add upstream https://github.com/otheruser/repo.git
# Set a new remote
  • 1
  • 2

添加后再查看远程仓库会有以下结果

$ git remote -v
# Verify new remote
origin    https://github.com/user/repo.git (fetch)
origin    https://github.com/user/repo.git (push)
upstream  https://github.com/otheruser/repo.git (fetch)
upstream  https://github.com/otheruser/repo.git (push)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

3. 获取上游分支

$ git fetch upstream
# Grab the upstream remote's branches
remote: Counting objects: 75, done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 62 (delta 27), reused 44 (delta 9)
Unpacking objects: 100% (62/62), done.
From https://github.com/otheruser/repo
 * [new branch]      master     -> upstream/master
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

查看所有分支:

$ git branch -va
# List all local and remote-tracking branches
* master                  a422352 My local commit
  remotes/origin/HEAD     -> origin/master
  remotes/origin/master   a422352 My local commit
  remotes/upstream/master 5fdff0f Some upstream commit
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

4. 合并上游分支

$ git merge upstream/master
# Merge upstream's master into our own
Updating a422352..5fdff0f
Fast-forward
 README                    |    9 -------
 README.md                 |    7 ++++++
 2 files changed, 7 insertions(+), 9 deletions(-)
 delete mode 100644 README
 create mode 100644 README.md
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/846194
推荐阅读
相关标签
  

闽ICP备14008679号