第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何撤消已完成的“ git commit --amend”而不是“ git commit”

如何撤消已完成的“ git commit --amend”而不是“ git commit”

Git
萬千封印 2019-11-21 10:21:32
我不小心修改了以前的提交。提交應(yīng)該分開進(jìn)行,以保留我對(duì)特定文件所做更改的歷史記錄。有什么方法可以撤消上一次提交?如果我做類似的事情git reset --hard HEAD^,那么第一次提交也將被撤消。(我尚未推送到任何遠(yuǎn)程目錄)
查看完整描述

3 回答

?
慕田峪9158850

TA貢獻(xiàn)1794條經(jīng)驗(yàn) 獲得超8個(gè)贊

您需要做的是創(chuàng)建一個(gè)新提交,其詳細(xì)信息與當(dāng)前HEAD提交相同,但其父級(jí)為的早期版本HEAD。git reset --soft將移動(dòng)分支指針,以便下一次提交發(fā)生在與當(dāng)前分支頭所在位置不同的提交之上。


# Move the current head so that it's pointing at the old commit

# Leave the index intact for redoing the commit.

# HEAD@{1} gives you "the commit that HEAD pointed at before 

# it was moved to where it currently points at". Note that this is

# different from HEAD~1, which gives you "the commit that is the

# parent node of the commit that HEAD is currently pointing to."

git reset --soft HEAD@{1}


# commit the current tree using the commit details of the previous

# HEAD commit. (Note that HEAD@{1} is pointing somewhere different from the

# previous command. It's now pointing at the erroneously amended commit.)

git commit -C HEAD@{1}


查看完整回答
反對(duì) 回復(fù) 2019-11-21
?
一只名叫tom的貓

TA貢獻(xiàn)1906條經(jīng)驗(yàn) 獲得超3個(gè)贊

通過以下方式查找修改后的提交:


git log --reflog

注意:--patch為了清楚起見,您可以添加以查看提交的正文。與相同git reflog。


然后通過以下方法將HEAD重置為以前的任何提交:


git reset SHA1 --hard

注意:將 SHA1 替換為實(shí)際的提交哈希。另請(qǐng)注意,此命令將丟失所有未提交的更改,因此您可以將它們存放在前面?;蛘撸挠?-soft保留最新的更改,然后提交。


然后在它上面挑選另一個(gè)提交:


git cherry-pick SHA1


查看完整回答
反對(duì) 回復(fù) 2019-11-21
  • 3 回答
  • 0 關(guān)注
  • 992 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)