亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

結合Git存儲庫的前兩個提交?

結合Git存儲庫的前兩個提交?

Git
繁花如伊 2019-08-15 14:04:47
結合Git存儲庫的前兩個提交?假設您有一個包含三個提交A,B和C的歷史記錄:A-B-C我想將兩個提交A和B組合到一個提交AB:AB-C我試過了git rebase -i A這打開了我的編輯器,其中包含以下內容:pick e97a17b Bpick asd314f C我改成這個squash e97a17b Bpick asd314f C然后Git 1.6.0.4說:Cannot 'squash' without a previous commit有辦法還是不可能?
查看完整描述

3 回答

?
largeQ

TA貢獻2039條經驗 獲得超8個贊

使用git rebase -i --root 作為的Git 版本1.7.12。

在互動變基文件,改變提交的第二線壓扁并保留其他線路的挑選

pick f4202da Asquash bea708e Bpick a8c6abc C

這將把兩個提交AB組合成一個提交AB。


查看完整回答
反對 回復 2019-08-15
?
烙印99

TA貢獻1829條經驗 獲得超13個贊

你試過:

git rebase -i A

如果你繼續edit而不是squash:有可能這樣開始:

edit e97a17b Bpick asd314f C

然后運行

git reset --soft HEAD^
git commit --amend
git rebase --continue

完成。


查看完整回答
反對 回復 2019-08-15
?
慕哥9229398

TA貢獻1877條經驗 獲得超6個贊

A是最初的提交,但現在你想B成為最初的提交。git提交是整個樹,而不是差異,即使它們通常是根據它們引入的差異來描述和查看的。


即使A和B以及B和C之間有多個提交,此配方仍然有效。


# Go back to the last commit that we want

# to form the initial commit (detach HEAD)

git checkout <sha1_for_B>


# reset the branch pointer to the initial commit,

# but leaving the index and working tree intact.

git reset --soft <sha1_for_A>


# amend the initial tree using the tree from 'B'

git commit --amend


# temporarily tag this new initial commit

# (or you could remember the new commit sha1 manually)

git tag tmp


# go back to the original branch (assume master for this example)

git checkout master


# Replay all the commits after B onto the new initial commit

git rebase --onto tmp <sha1_for_B>


# remove the temporary tag

git tag -d tmp


查看完整回答
反對 回復 2019-08-15
  • 3 回答
  • 0 關注
  • 538 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號