git rebase详解

git rebase 处理流程

bill@ars:~/go/src/github.com/filecoin-project/lotus-office$ git branch 
  master
  master-1211
  master-ars
  master-ars-test

* master-rebase   // 我们自己的代码
  office-brower
  office-master
  pnet-office-130.26
  pnet-office-130.5
  pnet-office-162
  pnet-office-182
  pnet-office-32G
  pnet-office-99
  test2-0114
  test2-0116
  test2-gofmt
  testnet2
  bill@ars:~/go/src/github.com/filecoin-project/lotus-office$ git rebase office/master 
  First, rewinding head to replay your work on top of it...
  Applying: Update script for prinet
  Applying: +:create pri net
  Applying: tmp update
  Applying: update
  Applying: 修改私网部署脚本
  Applying: cmd/lotus-seal-worker/sub.go
  Applying: cmd/lotus-seal-worker/sub.go
  Applying: 合并最新代码到71ad238,处理私网部署问题
  Applying: 集群部署脚本
  Applying: filter specified miner msg
  Using index info to reconstruct a base tree...
  M    miner/miner.go
  Falling back to patching base and 3-way merge...
  Auto-merging miner/miner.go
  CONFLICT (content): Merge conflict in miner/miner.go  // 有冲突,解决冲突
  error: Failed to merge in the changes.
  Patch failed at 0010 filter specified miner msg
  The copy of the patch that failed is found in: .git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
解决了这个问题之后,运行“git rebase——continue”。
如果您想跳过这个补丁,可以运行“git rebase——skip”。
要签出原始分支并停止重设,请运行“git rebase——abort”。


bill@ars:~/go/src/github.com/filecoin-project/lotus-office$ 

image-20210506172931366

git rebase origin/master // 是在origin/master的基础上把我们的修改添加进来,origin/master是当前的代码,我们的修改是incoming的代码

<<<<<<< b71835f1adbcb26acffcdfb894a69804da94608f    
        "fmt"
=======
        "encoding/json"
        "io/ioutil"
>>>>>>> filter specified miner msg                                                 
// <<<< 到 ==== 是office/master当前的修改,commit为b71835f
// ==== 到 >>>> 是我们的代码,提交commit信息为filter specified miner msg

bill@ars:~/go/src/github.com/filecoin-project/lotus-office$ git status

rebase in progress; onto b02eaee

You are currently rebasing branch 'master-rebase' on 'b02eaee'.  // b02eaee Merge pull request #1100 from filecoin-project/feat/blizzar-fork 是官方最新的commit

  (fix conflicts and then run "git rebase --continue")  (修复冲突,然后运行“git rebase——continue”)

  (use "git rebase --skip" to skip this patch)  (使用“git rebase—skip”跳过此补丁)

  (use "git rebase --abort" to check out the original branch)  (使用“git rebase——abort”检查原始分支)


Unmerged paths:  未合并的路径,指还未合并到git管理的路径代码

  (use "git reset HEAD <file>..." to unstage)      (使用“git reset HEAD …”来删除)

  (use "git add <file>..." to mark resolution)      (使用“git添加<文件>…”来标记解决)



        both modified:   miner/miner.go



Changes not staged for commit:   未提交的更改: 

  (use "git add <file>..." to update what will be committed)  (使用“git添加<文件>…”来更新将要提交的内容)

  (use "git checkout -- <file>..." to discard changes in working directory)  (使用“git checkout—…”来放弃工作目录中的更改)

  (commit or discard the untracked or modified content in submodules) (提交或放弃子模块中未跟踪或修改的内容)



        modified:   extern/filecoin-ffi (new commits, modified content)



no changes added to commit (use "git add" and/or "git commit -a")

bill@ars:~/go/src/github.com/filecoin-project/lotus-office$ git add miner/miner.go 

bill@ars:~/go/src/github.com/filecoin-project/lotus-office$ git status

rebase in progress; onto b02eaee

You are currently rebasing branch 'master-rebase' on 'b02eaee'.

  (all conflicts fixed: run "git rebase --continue")



Changes to be committed:

  (use "git reset HEAD <file>..." to unstage)



        modified:   miner/miner.go



Changes not staged for commit:

  (use "git add <file>..." to update what will be committed)

  (use "git checkout -- <file>..." to discard changes in working directory)

  (commit or discard the untracked or modified content in submodules)



        modified:   extern/filecoin-ffi (new commits, modified content)
bill@ars:~/go/src/github.com/filecoin-project/lotus-office$ git rebase --continue      // 解决完冲突之后git rebase --continue,重复以上步骤知道rebase完成
bill@ars:~/go/src/github.com/filecoin-project/lotus-office$ git branch    // 如果出现no branch,是因为  ,git rebase --abort即可
* (no branch, rebasing master-rebase)
  master
  master-1211
  master-ars
  master-ars-test
  master-rebase
  office-brower
  office-master
  pnet-office-130.26
  pnet-office-130.5
  pnet-office-162
  pnet-office-182
  pnet-office-32G
  pnet-office-99
  test2-0114
  test2-0116
  test2-gofmt
  testnet2
bill@ars:~/go/src/github.com/filecoin-project/lotus-office$ git status
rebase in progress; onto b02eaee
You are currently rebasing branch 'master-rebase' on 'b02eaee'.
  (fix conflicts and then run "git rebase --continue")
  (use "git rebase --skip" to skip this patch)
  (use "git rebase --abort" to check out the original branch)

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   api/api_storage.go
        modified:   storage/miner.go
        new file:   storage/proving_service.go
        modified:   storage/sectors.go

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        both modified:   storage/sector_states.go

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

        modified:   extern/filecoin-ffi (new commits, modified content)


   转载规则


《git rebase详解》 bill 采用 知识共享署名 4.0 国际许可协议 进行许可。
 上一篇
网络分层的真实含义是什么? 网络分层的真实含义是什么?
长时间从事计算机网络相关的工作,我发现,计算机网络有一个显著的特点,就是这是一个不仅需要背诵,而且特别需要将原理烂熟于胸的学科。很多问题看起来懂了,但是就怕往细里问,一问就发现你懂得没有那么透彻。 我们上一节列了之后要讲的网络协议。这些协议
2020-03-11
下一篇 
gomod使用 gomod使用
在go mod 的require里面引入项目的last commit id由于不知道哪个版本号,那么在require里面使用最近一次提交的commit id: 510aa62 go 1.3.3 require ( git.xx.cn
2020-03-11
  目录