2013-08-02 25 views
1

我的遠程回購的主分支看起來像這樣(每一個提交):GIT:如果我已經向我的主分支提交了,我該如何處理一個請求?

一個 - B - C - d - 電子 - F - 摹

我想獲得一個代碼審查,DIFFSÇ和G(C不應該顯示C的變化)。我該怎麼做呢?

我必須

- create tmpBranch at master (pointing to G) 
- branch from C (newBranch) 
- move my master branch to newBranch 
- delete newBranch 
- push these branch changes to repo 
- submit pull request 

或有更簡單的方法呢?如果否,那麼將執行上述操作的命令是什麼?

回答

2

分支只是HEAD提交的標籤。所以,你基本上只需要改變標籤。

改變公共歷史不是一個好主意,除非你的回購是你自己的。所以,我假設沒有人使用你的master分支。

$ git checkout G 
$ git checkout -b review-this   # Create the branch to be reviewed. 
$ git checkout master 
$ git reset --hard C     # Reset the master to commit C 
$ git push -f <remote-name> master # Force push the master branch 
$ git push <remote-name> review-this # Push the new branch 
# Submit the pull request 
+1

謝謝,在我承諾掌握了一個從開源項目克隆的項目之後,這幫了我很大的忙。後來我想提交一個pull請求到項目中,所以我把我的老主人改爲'myproject-master',並進行了硬重置並拉開了開源的主分支。然後我又能夠在開源項目上進行合作。謝謝! – modulitos

相關問題