github同步原项目代码到fork项目

下面操作都在本地进行

设置上游项目

查看是否设置上游项目

>> git remote -v
origin	[email protected]:***/ord.git (fetch)
origin	[email protected]:***/ord.git (push)

这里只有两行origin表示没有设置上游项目,这里upstream是一个别名

>> git remote add upstream [email protected]:ordinals/ord.git

执行git remote add没有输出,再查看是否设置上游项目

>> git remote -v
origin	[email protected]:***/ord.git (fetch)
origin	[email protected]:***/ord.git (push)
upstream	[email protected]:ordinals/ord.git (fetch)
upstream	[email protected]:ordinals/ord.git (push)

设置上游项目完成

合并代码

合并上游项目代码,这里分别以fork项目已存在的分支和fork项目不存在的tag分支为例。先拉取上游项目代码

>> git fetch upstream
remote: Enumerating objects: 731, done.
remote: Counting objects: 100% (507/507), done.
remote: Compressing objects: 100% (103/103), done.
remote: Total 731 (delta 427), reused 439 (delta 404), pack-reused 224
Receiving objects: 100% (731/731), 723.13 KiB | 781.00 KiB/s, done.
Resolving deltas: 100% (500/500), completed with 86 local objects.
From github.com:ordinals/ord
 * [new branch]      all-json               -> upstream/all-json
 * [new branch]      api                    -> upstream/api
 * [new branch]      blake3-etag            -> upstream/blake3-etag
 * [new branch]      deploy                 -> upstream/deploy
 * [new branch]      deploy-mainnet         -> upstream/deploy-mainnet
 * [new branch]      export-files           -> upstream/export-files
 * [new branch]      fix-mainnet            -> upstream/fix-mainnet
 * [new branch]      fuzz-with-inscribed-utxos -> upstream/fuzz-with-inscribed-utxos
 * [new branch]      gh-pages               -> upstream/gh-pages
 * [new branch]      master                 -> upstream/master
 * [new branch]      multimaps              -> upstream/multimaps
 * [new branch]      nega-inscriptions      -> upstream/nega-inscriptions
 * [new branch]      offers                 -> upstream/offers
 * [new branch]      pixelate               -> upstream/pixelate
 * [new branch]      teleburn               -> upstream/teleburn
 * [new branch]      template-struct-tests  -> upstream/template-struct-tests
 * [new branch]      unsupported-mime-types -> upstream/unsupported-mime-types
 * [new tag]         0.7.0                  -> 0.7.0
 * [new tag]         0.5.2                  -> 0.5.2
 * [new tag]         0.6.0                  -> 0.6.0
 * [new tag]         0.6.1                  -> 0.6.1
 * [new tag]         0.6.2                  -> 0.6.2

合并master

1、切换到master分支
2、合并上游master代码
3、推送到fork项目

>> git checkout master
Switched to branch 'master'
>> git merge upstream/master
>> git push origin master:master

同步新tag

1、切换到tag
2、推送tag到fork项目(注意:tag推送后不能修改,修改后只能新建tag)

>> git checkout 0.6.2
Switched to branch '0.6.2'
>> git push origin HEAD:refs/tags/0.6.2
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 8 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 548 bytes | 274.00 KiB/s, done.
Total 6 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To github.com:btccom/ord.git
 * [new tag]         HEAD -> 0.6.2

猜你喜欢

转载自blog.csdn.net/chinesesexyman/article/details/131394848