日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

git rebase 简介

發(fā)布時間:2023/12/14 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 git rebase 简介 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

前言

使用場景

主要功能是編輯git提交歷史,所以建議在私有分支使用!

rebase使用方法

1. 開始變基

git rebase -i master (不一定對比分支,也可以對比某個提交點)

執(zhí)行命令后出現(xiàn)提交歷史:

pick 4daa490d 1 pick a996b550 ar pick 2b43e8b1 2 pick 8e71f26f as pick 37817519 3 pick 876680bd af pick 8ddef852 4 pick 631d56b5 ad pick 4814d62b 5 復(fù)制代碼

2. 進行修改

往下拉會看見命令提示:

# Commands: # p, pick <commit> = use commit # r, reword <commit> = use commit, but edit the commit message # e, edit <commit> = use commit, but stop for amending # s, squash <commit> = use commit, but meld into previous commit # f, fixup <commit> = like "squash", but discard this commit's log message # x, exec <command> = run command (the rest of the line) using shell # d, drop <commit> = remove commit # l, label <label> = label current HEAD with a name # t, reset <label> = reset HEAD to a label # m, merge [-C <commit> | -c <commit>] <label> [# <oneline>] 復(fù)制代碼

解釋一下上面的命令:(完整提交 = 提交內(nèi)容 + 提交日志)

pick:該提交保留 reword:提交內(nèi)容不變,但是編輯提交日志 squash:提交內(nèi)容和提交日志合并至上次提交(提交日志合并時可編輯) fixup:提交內(nèi)容合并至上次提交,提交日志不合并(刪除提交日志) drop:刪除本次提交內(nèi)容和提交日志 復(fù)制代碼

單獨說一下edit這個命令:

回滾至當次提交(未提交狀態(tài),保留提交內(nèi)容) 然后你可以修改當次提交內(nèi)容,可以添加或者拆分提交!(月光寶盒時光倒流功能) 修改完畢后執(zhí)行:git rebase --continue 復(fù)制代碼

3. 測試結(jié)果

假設(shè)修改設(shè)置如下:

pick 4daa490d 1 reword a996b550 ar pick 2b43e8b1 2 squash 8e71f26f as pick 37817519 3 fixup 876680bd af pick 8ddef852 4 drop 631d56b5 ad pick 4814d62b 5 復(fù)制代碼

最終效果:

4daa490d 1 a996b550 ar reword 2b43e8b1 2 as squash 37817519 3 8ddef852 4 4814d62b 5 復(fù)制代碼

備用方案

git merge --squash dev

--squash選項作用:合并后不自動提交,相當于用分支的文件覆蓋當前主干的文件

優(yōu)點:主干提交記錄非常干凈。

缺點:丟失分支提交記錄。

后語

建議大家多實踐測試,才能理解透徹該命令的使用方法!

推薦使用圖形工具進行操作,方便又不容易出錯!

轉(zhuǎn)載于:https://juejin.im/post/5c8c549ee51d45257c2f7a28

總結(jié)

以上是生活随笔為你收集整理的git rebase 简介的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。