iT邦幫忙

1

Git 歷史 commit 的問題

git
  • 分享至 

  • xImage

我在 Git 總共有 commit 1、2、3、4、5 ,我現在想要 commit 回原本 commit 1 的內容,但還要保留 commit 2、3、4、5 的歷史,請問要怎麼做,謝謝?

看更多先前的討論...收起先前的討論...
tomtomtom iT邦新手 4 級 ‧ 2024-04-02 16:56:33 檢舉
你的意思是要回到commit 1後的狀態,但2,3,4,5所做的更改要回到working directory裡嗎
samjam iT邦新手 3 級 ‧ 2024-04-02 17:08:01 檢舉
不是。
我是想要原本 commit 1、2、3、4、5 ,之後再 commit 6,而這個 commit 6 的內容是原本 commit 1 的內容。
最後的歷史是 commit 1、2、3、4、5、6。
高見龍 iT邦研究生 4 級 ‧ 2024-04-02 19:29:46 檢舉
看起來像是要調整順序?

如果是的話,可以用 git rebase -i 來調整 :)
frogsoul iT邦研究生 5 級 ‧ 2024-04-03 08:15:14 檢舉
感覺上他的commit 6,其實是要做"rollback的動作"到節點1
DennisLu iT邦研究生 1 級 ‧ 2024-04-03 10:25:50 檢舉
切換到 1 然後開分支修改,這分支再跟6合併。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
1
alien663
iT邦研究生 5 級 ‧ 2024-04-02 17:25:24

有個不錯的學習網站,你可以試試
Learn Git Branching

samjam iT邦新手 3 級 ‧ 2024-04-10 10:39:36 檢舉

這網站對我有幫助,謝謝

2
janlin002
iT邦好手 1 級 ‧ 2024-04-02 18:06:55

git 如果要調整 commit 的順序,推薦可以使用 rebase

samjam iT邦新手 3 級 ‧ 2024-04-10 10:39:00 檢舉

謝謝,我再試試。

2
高見龍
iT邦研究生 4 級 ‧ 2024-04-02 19:30:31

看起來像是要調整順序?

如果是的話,可以用 git rebase -i 來調整 :)

samjam iT邦新手 3 級 ‧ 2024-04-10 10:39:15 檢舉

我研究一下,謝謝

我要發表回答

立即登入回答