iT邦幫忙

0

Git問題 : 如何A改名B時,B還保有A的所有 git history

git
  • 分享至 

  • xImage

常常一開始命名維運腳本命名不好
中間做了一些修改並做git版本控

結果後面強迫症犯了,想要改名
像是A改名為B,改完後發現 git history 都不見了...

所以詢問 git 大神們如何解決 "A改名B時,B還保有A的所有 git history" 問題

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

3
兩津勘吉
iT邦新手 4 級 ‧ 2020-08-18 16:52:55
最佳解答

如果是團隊開發的專案,其實建議你不要這樣做...這樣只會製造團隊的困擾,因爲後面推回去的時候要加 --force 硬推

可以更改最後一次的 commit
git commit --amend

第二次的 commit,把想更改的 commit 前面的 pick 改成 edit 儲存
git rebase -i HEAD~2

接著修改 commit
git commit --amend

修改完之後儲存
git rebase --continue

原來還有這樣操作,感謝 兩津勘吉 大神

我要發表回答

立即登入回答