1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問(wèn)題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
      怎么用Git變基來(lái)改變歷史

      這篇文章給大家分享的是有關(guān)怎么用Git變基來(lái)改變歷史的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

      10年積累的成都網(wǎng)站制作、做網(wǎng)站經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先做網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有廣水免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

      Git  核心的附加價(jià)值之一就是編輯歷史記錄的能力。與將歷史記錄視為神圣的記錄的版本控制系統(tǒng)不同,在 Git  中,我們可以修改歷史記錄以適應(yīng)我們的需要。這為我們提供了很多強(qiáng)大的工具,讓我們可以像使用重構(gòu)來(lái)維護(hù)良好的軟件設(shè)計(jì)實(shí)踐一樣,編織良好的提交歷史。這些工具對(duì)于新手甚至是有經(jīng)驗(yàn)的  Git 用戶來(lái)說(shuō)可能會(huì)有些令人生畏,但本指南將幫助我們揭開(kāi)強(qiáng)大的 git-rebase 的神秘面紗。

      值得注意的是:一般建議不要修改公共分支、共享分支或穩(wěn)定分支的歷史記錄。編輯特性分支和個(gè)人分支的歷史記錄是可以的,編輯還沒(méi)有推送的提交也是可以的。在編輯完提交后,可以使用 git push -f 來(lái)強(qiáng)制推送你的修改到個(gè)人分支或特性分支。

      盡管有這么可怕的警告,但值得一提的是,本指南中提到的一切都是非破壞性操作。實(shí)際上,在 Git 中永久丟失數(shù)據(jù)是相當(dāng)困難的。本指南結(jié)尾介紹了在犯錯(cuò)誤時(shí)進(jìn)行糾正的方法。

      設(shè)置沙盒

      我們不想破壞你的任何實(shí)際的版本庫(kù),所以在整個(gè)指南中,我們將使用一個(gè)沙盒版本庫(kù)。運(yùn)行這些命令來(lái)開(kāi)始工作。1

      git init /tmp/rebase-sandboxcd /tmp/rebase-sandboxgit commit --allow-empty -m"Initial commit"

      如果你遇到麻煩,只需運(yùn)行 rm -rf /tmp/rebase-sandbox,并重新運(yùn)行這些步驟即可重新開(kāi)始。本指南的每一步都可以在新的沙箱上運(yùn)行,所以沒(méi)有必要重做每個(gè)任務(wù)。

      修正最近的提交

      讓我們從簡(jiǎn)單的事情開(kāi)始:修復(fù)你最近的提交。讓我們向沙盒中添加一個(gè)文件,并犯?jìng)€(gè)錯(cuò)誤。

      echo "Hello wrold!" >greeting.txtgit add greeting.txtgit commit -m"Add greeting.txt"

      修復(fù)這個(gè)錯(cuò)誤是非常容易的。我們只需要編輯文件,然后用 --amend 提交就可以了,就像這樣:

      echo "Hello world!" >greeting.txtgit commit -a --amend

      指定 -a 會(huì)自動(dòng)將所有 Git 已經(jīng)知道的文件進(jìn)行暫存(例如 Git 添加的),而 --amend 會(huì)將更改的內(nèi)容壓扁到最近的提交中。保存并退出你的編輯器(如果需要,你現(xiàn)在可以修改提交信息)。你可以通過(guò)運(yùn)行 git show 看到修復(fù)的提交。

      commit f5f19fbf6d35b2db37dcac3a55289ff9602e4d00 (HEAD -> master)Author: Drew DeVault Date:   Sun Apr 28 11:09:47 2019 -0400     Add greeting.txt diff --git a/greeting.txt b/greeting.txtnew file mode 100644index 0000000..cd08755--- /dev/null+++ b/greeting.txt@@ -0,0 +1 @@+Hello world!

      修復(fù)較舊的提交

      --amend 僅適用于最近的提交。如果你需要修正一個(gè)較舊的提交會(huì)怎么樣?讓我們從相應(yīng)地設(shè)置沙盒開(kāi)始:

      echo "Hello!" >greeting.txtgit add greeting.txtgit commit -m"Add greeting.txt" echo "Goodbye world!" >farewell.txtgit add farewell.txtgit commit -m"Add farewell.txt"

      看起來(lái) greeting.txt 像是丟失了 "world"。讓我們正常地寫個(gè)提交來(lái)解決這個(gè)問(wèn)題:

      echo "Hello world!" >greeting.txtgit commit -a -m"fixup greeting.txt"

      現(xiàn)在文件看起來(lái)正確,但是我們的歷史記錄可以更好一點(diǎn) —— 讓我們使用新的提交來(lái)“修復(fù)”(fixup)最后一個(gè)提交。為此,我們需要引入一個(gè)新工具:交互式變基。我們將以這種方式編輯最后三個(gè)提交,因此我們將運(yùn)行 git rebase -i HEAD~3-i 代表交互式)。這樣會(huì)打開(kāi)文本編輯器,如下所示:

      pick 8d3fc77 Add greeting.txtpick 2a73a77 Add farewell.txtpick 0b9d0bb fixup greeting.txt # Rebase f5f19fb..0b9d0bb onto f5f19fb (3 commands)## Commands:# p, pick  = use commit# f, fixup  = like "squash", but discard this commit's log message

      這是變基計(jì)劃,通過(guò)編輯此文件,你可以指導(dǎo) Git 如何編輯歷史記錄。我已經(jīng)將該摘要削減為僅與變基計(jì)劃這一部分相關(guān)的細(xì)節(jié),但是你可以在文本編輯器中瀏覽完整的摘要。

      當(dāng)我們保存并關(guān)閉編輯器時(shí),Git 將從其歷史記錄中刪除所有這些提交,然后一次執(zhí)行一行。默認(rèn)情況下,它將選?。?code>pick)每個(gè)提交,將其從堆中召喚出來(lái)并添加到分支中。如果我們對(duì)此文件根本沒(méi)有做任何編輯,則將直接回到起點(diǎn),按原樣選取每個(gè)提交?,F(xiàn)在,我們將使用我最喜歡的功能之一:修復(fù)(fixup)。編輯第三行,將操作從 pick 更改為 fixup,并將其立即移至我們要“修復(fù)”的提交之后:

      pick 8d3fc77 Add greeting.txtfixup 0b9d0bb fixup greeting.txtpick 2a73a77 Add farewell.txt

      技巧:我們也可以只用 f 來(lái)縮寫它,以加快下次的速度。

      保存并退出編輯器,Git 將運(yùn)行這些命令。我們可以檢查日志以驗(yàn)證結(jié)果:

      $ git log -2 --onelinefcff6ae (HEAD -> master) Add farewell.txta479e94 Add greeting.txt

      將多個(gè)提交壓扁為一個(gè)

      在工作時(shí),當(dāng)你達(dá)到較小的里程碑或修復(fù)以前的提交中的錯(cuò)誤時(shí),你可能會(huì)發(fā)現(xiàn)寫很多提交很有用。但是,在將你的工作合并到 master 分支之前,將這些提交“壓扁”(squash)到一起以使歷史記錄更清晰可能很有用。為此,我們將使用“壓扁”(squash)操作。讓我們從編寫一堆提交開(kāi)始,如果要加快速度,只需復(fù)制并粘貼這些:

      git checkout -b squashfor c in H e l l o , ' ' w o r l d; do    echo "$c" >>squash.txt    git add squash.txt    git commit -m"Add '$c' to squash.txt"done

      要制作出一個(gè)寫著 “Hello,world” 的文件,要做很多事情!讓我們開(kāi)始另一個(gè)交互式變基,將它們壓扁在一起。請(qǐng)注意,我們首先簽出了一個(gè)分支來(lái)進(jìn)行嘗試。因此,因?yàn)槲覀兪褂?git rebase -i master 進(jìn)行的分支,我們可以快速變基所有提交。結(jié)果:

      pick 1e85199 Add 'H' to squash.txtpick fff6631 Add 'e' to squash.txtpick b354c74 Add 'l' to squash.txtpick 04aaf74 Add 'l' to squash.txtpick 9b0f720 Add 'o' to squash.txtpick 66b114d Add ',' to squash.txtpick dc158cd Add ' ' to squash.txtpick dfcf9d6 Add 'w' to squash.txtpick 7a85f34 Add 'o' to squash.txtpick c275c27 Add 'r' to squash.txtpick a513fd1 Add 'l' to squash.txtpick 6b608ae Add 'd' to squash.txt # Rebase 1af1b46..6b608ae onto 1af1b46 (12 commands)## Commands:# p, pick  = use commit# s, squash  = use commit, but meld into previous commit

      技巧:你的本地 master 分支獨(dú)立于遠(yuǎn)程 master 分支而發(fā)展,并且 Git 將遠(yuǎn)程分支存儲(chǔ)為 origin/master。結(jié)合這種技巧,git rebase -i origin/master 通常是一種非常方便的方法,可以變基所有尚未合并到上游的提交!

      我們將把所有這些更改壓扁到第一個(gè)提交中。為此,將第一行除外的每個(gè)“選取”(pick)操作都更改為“壓扁”(squash),如下所示:

      pick 1e85199 Add 'H' to squash.txtsquash fff6631 Add 'e' to squash.txtsquash b354c74 Add 'l' to squash.txtsquash 04aaf74 Add 'l' to squash.txtsquash 9b0f720 Add 'o' to squash.txtsquash 66b114d Add ',' to squash.txtsquash dc158cd Add ' ' to squash.txtsquash dfcf9d6 Add 'w' to squash.txtsquash 7a85f34 Add 'o' to squash.txtsquash c275c27 Add 'r' to squash.txtsquash a513fd1 Add 'l' to squash.txtsquash 6b608ae Add 'd' to squash.txt

      保存并關(guān)閉編輯器時(shí),Git 會(huì)考慮片刻,然后再次打開(kāi)編輯器以修改最終的提交消息。你會(huì)看到以下內(nèi)容:

      # This is a combination of 12 commits.# This is the 1st commit message: Add 'H' to squash.txt # This is the commit message #2: Add 'e' to squash.txt # This is the commit message #3: Add 'l' to squash.txt # This is the commit message #4: Add 'l' to squash.txt # This is the commit message #5: Add 'o' to squash.txt # This is the commit message #6: Add ',' to squash.txt # This is the commit message #7: Add ' ' to squash.txt # This is the commit message #8: Add 'w' to squash.txt # This is the commit message #9: Add 'o' to squash.txt # This is the commit message #10: Add 'r' to squash.txt # This is the commit message #11: Add 'l' to squash.txt # This is the commit message #12: Add 'd' to squash.txt # Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.## Date:      Sun Apr 28 14:21:56 2019 -0400## interactive rebase in progress; onto 1af1b46# Last commands done (12 commands done):#    squash a513fd1 Add 'l' to squash.txt#    squash 6b608ae Add 'd' to squash.txt# No commands remaining.# You are currently rebasing branch 'squash' on '1af1b46'.## Changes to be committed:#   new file:   squash.txt#

      默認(rèn)情況下,這是所有要壓扁的提交的消息的組合,但是像這樣將其保留肯定不是你想要的。不過(guò),舊的提交消息在編寫新的提交消息時(shí)可能很有用,所以放在這里以供參考。

      提示:你在上一節(jié)中了解的“修復(fù)”(fixup)命令也可以用于此目的,但它會(huì)丟棄壓扁的提交的消息。

      讓我們刪除所有內(nèi)容,并用更好的提交消息替換它,如下所示:

      Add squash.txt with contents "Hello, world" # Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.## Date:      Sun Apr 28 14:21:56 2019 -0400## interactive rebase in progress; onto 1af1b46# Last commands done (12 commands done):#    squash a513fd1 Add 'l' to squash.txt#    squash 6b608ae Add 'd' to squash.txt# No commands remaining.# You are currently rebasing branch 'squash' on '1af1b46'.## Changes to be committed:#   new file:   squash.txt#

      保存并退出編輯器,然后檢查你的 Git 日志,成功!

      commit c785f476c7dff76f21ce2cad7c51cf2af00a44b6 (HEAD -> squash)Author: Drew DeVaultDate:   Sun Apr 28 14:21:56 2019 -0400     Add squash.txt with contents "Hello, world"

      在繼續(xù)之前,讓我們將所做的更改拉入 master 分支中,并擺脫掉這一草稿。我們可以像使用 git merge 一樣使用 git rebase,但是它避免了創(chuàng)建合并提交:

      git checkout mastergit rebase squashgit branch -D squash

      除非我們實(shí)際上正在合并無(wú)關(guān)的歷史記錄,否則我們通常希望避免使用 git merge。如果你有兩個(gè)不同的分支,則 git merge 對(duì)于記錄它們合并的時(shí)間非常有用。在正常工作過(guò)程中,變基通常更為合適。

      將一個(gè)提交拆分為多個(gè)

      有時(shí)會(huì)發(fā)生相反的問(wèn)題:一個(gè)提交太大了。讓我們來(lái)看一看拆分它們。這次,讓我們寫一些實(shí)際的代碼。從一個(gè)簡(jiǎn)單的 C 程序 2 開(kāi)始(你仍然可以將此代碼段復(fù)制并粘貼到你的 shell 中以快速執(zhí)行此操作):

      cat <main.cint main(int argc, char *argv[]) {    return 0;}EOF

      首先提交它:

      git add main.cgit commit -m"Add C program skeleton"

      然后把這個(gè)程序擴(kuò)展一些:

      cat <main.c#include <stdio.h> const char *get_name() {    static char buf[128];    scanf("%s", buf);    return buf;} int main(int argc, char *argv[]) {    printf("What's your name? ");    const char *name = get_name();    printf("Hello, %s!\n", name);    return 0;}EOF

      提交之后,我們就可以準(zhǔn)備學(xué)習(xí)如何將其拆分:

      git commit -a -m"Flesh out C program"

      第一步是啟動(dòng)交互式變基。讓我們用 git rebase -i HEAD~2 來(lái)變基這兩個(gè)提交,給出的變基計(jì)劃如下:

      pick 237b246 Add C program skeletonpick b3f188b Flesh out C program # Rebase c785f47..b3f188b onto c785f47 (2 commands)## Commands:# p, pick  = use commit# e, edit  = use commit, but stop for amending

      將第二個(gè)提交的命令從 pick 更改為 edit,然后保存并關(guān)閉編輯器。Git 會(huì)考慮一秒鐘,然后向你建議:

      Stopped at b3f188b...  Flesh out C programYou can amend the commit now, with   git commit --amend Once you are satisfied with your changes, run   git rebase --continue

      我們可以按照以下說(shuō)明為提交添加新的更改,但我們可以通過(guò)運(yùn)行 git reset HEAD^ 來(lái)進(jìn)行“軟重置” 3。如果在此之后運(yùn)行 git status,你將看到它取消了提交最新的提交,并將其更改添加到工作樹(shù)中:

      Last commands done (2 commands done):   pick 237b246 Add C program skeleton   edit b3f188b Flesh out C programNo commands remaining.You are currently splitting a commit while rebasing branch 'master' on 'c785f47'.  (Once your working directory is clean, run "git rebase --continue") Changes not staged for commit:  (use "git add ..." to update what will be committed)  (use "git checkout -- ..." to discard changes in working directory)   modified:   main.c no changes added to commit (use "git add" and/or "git commit -a")

      為了對(duì)此進(jìn)行拆分,我們將進(jìn)行交互式提交。這使我們能夠選擇性地僅提交工作樹(shù)中的特定更改。運(yùn)行 git commit -p 開(kāi)始此過(guò)程,你將看到以下提示:

      diff --git a/main.c b/main.cindex b1d9c2c..3463610 100644--- a/main.c+++ b/main.c@@ -1,3 +1,14 @@+#include <stdio.h>++const char *get_name() {+    static char buf[128];+    scanf("%s", buf);+    return buf;+}+ int main(int argc, char *argv[]) {+    printf("What's your name? ");+    const char *name = get_name();+    printf("Hello, %s!\n", name);     return 0; }Stage this hunk [y,n,q,a,d,s,e,?]?

      Git 僅向你提供了一個(gè)“大塊”(即單個(gè)更改)以進(jìn)行提交。不過(guò),這太大了,讓我們使用 s 命令將這個(gè)“大塊”拆分成較小的部分。

      Split into 2 hunks.@@ -1 +1,9 @@+#include ++const char *get_name() {+    static char buf[128];+    scanf("%s", buf);+    return buf;+}+ int main(int argc, char *argv[]) {Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?

      提示:如果你對(duì)其他選項(xiàng)感到好奇,請(qǐng)按 ? 匯總顯示。

      這個(gè)大塊看起來(lái)更好:?jiǎn)我?、?dú)立的更改。讓我們按 y 來(lái)回答問(wèn)題(并暫存那個(gè)“大塊”),然后按 q 以“退出”交互式會(huì)話并繼續(xù)進(jìn)行提交。會(huì)彈出編輯器,要求輸入合適的提交消息。

      Add get_name function to C program # Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.## interactive rebase in progress; onto c785f47# Last commands done (2 commands done):#    pick 237b246 Add C program skeleton#    edit b3f188b Flesh out C program# No commands remaining.# You are currently splitting a commit while rebasing branch 'master' on 'c785f47'.## Changes to be committed:#   modified:   main.c## Changes not staged for commit:#   modified:   main.c#

      保存并關(guān)閉編輯器,然后我們進(jìn)行第二次提交。我們可以執(zhí)行另一次交互式提交,但是由于我們只想在此提交中包括其余更改,因此我們將執(zhí)行以下操作:

      git commit -a -m"Prompt user for their name"git rebase --continue

      最后一條命令告訴 Git 我們已經(jīng)完成了此提交的編輯,并繼續(xù)執(zhí)行下一個(gè)變基命令。這樣就行了!運(yùn)行 git log 來(lái)查看你的勞動(dòng)成果:

      $ git log -3 --onelinefe19cc3 (HEAD -> master) Prompt user for their name659a489 Add get_name function to C program237b246 Add C program skeleton

      重新排序提交

      這很簡(jiǎn)單。讓我們從設(shè)置沙箱開(kāi)始:

      echo "Goodbye now!" >farewell.txtgit add farewell.txtgit commit -m"Add farewell.txt" echo "Hello there!" >greeting.txtgit add greeting.txtgit commit -m"Add greeting.txt" echo "How're you doing?" >inquiry.txtgit add inquiry.txtgit commit -m"Add inquiry.txt"

      現(xiàn)在 git log 看起來(lái)應(yīng)如下所示:

      f03baa5 (HEAD -> master) Add inquiry.txta4cebf7 Add greeting.txt90bb015 Add farewell.txt

      顯然,這都是亂序。讓我們對(duì)過(guò)去的 3 個(gè)提交進(jìn)行交互式變基來(lái)解決此問(wèn)題。運(yùn)行 git rebase -i HEAD~3,這個(gè)變基規(guī)劃將出現(xiàn):

      pick 90bb015 Add farewell.txtpick a4cebf7 Add greeting.txtpick f03baa5 Add inquiry.txt # Rebase fe19cc3..f03baa5 onto fe19cc3 (3 commands)## Commands:# p, pick  = use commit## These lines can be re-ordered; they are executed from top to bottom.

      現(xiàn)在,解決方法很簡(jiǎn)單:只需按照你希望提交出現(xiàn)的順序重新排列這些行。應(yīng)該看起來(lái)像這樣:

      pick a4cebf7 Add greeting.txtpick f03baa5 Add inquiry.txtpick 90bb015 Add farewell.txt

      保存并關(guān)閉你的編輯器,而 Git 將為你完成其余工作。請(qǐng)注意,在實(shí)踐中這樣做可能會(huì)導(dǎo)致沖突,參看下面章節(jié)以獲取解決沖突的幫助。

      git pull –rebase

      如果你一直在由上游更新的分支 (比如說(shuō)原始遠(yuǎn)程)上做一些提交,通常 git pull 會(huì)創(chuàng)建一個(gè)合并提交。在這方面,git pull 的默認(rèn)行為等同于:

      git fetch origin git merge origin/

      假設(shè)本地分支 配置為從原始遠(yuǎn)程跟蹤 分支,即:

      $ git config branch..remoteorigin$ git config branch..mergerefs/heads/

      還有另一種選擇,它通常更有用,并且會(huì)讓歷史記錄更清晰:git pull --rebase。與合并方式不同,這基本上 4 等效于以下內(nèi)容:

      git fetch origingit rebase origin/

      合并方式更簡(jiǎn)單易懂,但是如果你了解如何使用 git rebase,那么變基方式幾乎可以做到你想要做的任何事情。如果愿意,可以將其設(shè)置為默認(rèn)行為,如下所示:

      git config --global pull.rebase true

      當(dāng)你執(zhí)行此操作時(shí),從技術(shù)上講,你在應(yīng)用我們?cè)谙乱还?jié)中討論的過(guò)程……因此,讓我們也解釋一下故意執(zhí)行此操作的含義。

      使用 git rebase 來(lái)變基

      具有諷刺意味的是,我最少使用的 Git 變基功能是它以之命名的功能:變基分支。假設(shè)你有以下分支:

      A--B--C--D--> master   \--E--F--> feature-1      \--G--> feature-2

      事實(shí)證明,feature-2 不依賴于 feature-1 的任何更改,它依賴于提交 E,因此你可以將其作為基礎(chǔ)脫離 master。因此,解決方法是:

      git rebase --onto master feature-1 feature-2

      非交互式變基對(duì)所有牽連的提交都執(zhí)行默認(rèn)操作(pick5 ,它只是簡(jiǎn)單地將不在 feature-1 中的 feature-2 中提交重放到 master 上。你的歷史記錄現(xiàn)在看起來(lái)像這樣:

      A--B--C--D--> master   |     \--G--> feature-2   \--E--F--> feature-1

      解決沖突

      解決合并沖突的詳細(xì)信息不在本指南的范圍內(nèi),將來(lái)請(qǐng)你注意另一篇指南。假設(shè)你熟悉通常的解決沖突的方法,那么這里是專門適用于變基的部分。

      有時(shí),在進(jìn)行變基時(shí)會(huì)遇到合并沖突,你可以像處理其他任何合并沖突一樣處理該沖突。Git 將在受影響的文件中設(shè)置沖突標(biāo)記,git status 將顯示你需要解決的問(wèn)題,并且你可以使用 git addgit rm 將文件標(biāo)記為已解決。但是,在 git rebase 的上下文中,你應(yīng)該注意兩個(gè)選項(xiàng)。

      首先是如何完成沖突解決。解決由于 git merge 引起的沖突時(shí),與其使用 git commit 那樣的命令,更適當(dāng)?shù)淖兓钍?git rebase --continue。但是,還有一個(gè)可用的選項(xiàng):git rebase --skip。 這將跳過(guò)你正在處理的提交,它不會(huì)包含在變基中。這在執(zhí)行非交互性變基時(shí)最常見(jiàn),這時(shí) Git 不會(huì)意識(shí)到它從“其他”分支中提取的提交是與“我們”分支上沖突的提交的更新版本。

      幫幫我! 我把它弄壞了!

      毫無(wú)疑問(wèn),變基有時(shí)會(huì)很難。如果你犯了一個(gè)錯(cuò)誤,并因此而丟失了所需的提交,那么可以使用 git reflog 來(lái)節(jié)省下一天的時(shí)間。運(yùn)行此命令將向你顯示更改一個(gè)引用(即分支和標(biāo)記)的每個(gè)操作。每行顯示你的舊引用所指向的內(nèi)容,你可對(duì)你認(rèn)為丟失的 Git 提交執(zhí)行 git cherry-pick、git checkout、git show 或任何其他操作。


      1. 鴻蒙官方戰(zhàn)略合作共建——HarmonyOS技術(shù)社區(qū)

      2. 我們添加了一個(gè)空的初始提交以簡(jiǎn)化本教程的其余部分,因?yàn)橐獙?duì)版本庫(kù)的初始提交進(jìn)行變基需要特殊的命令(即git rebase --root)。  ?

      3. 如果要編譯此程序,請(qǐng)運(yùn)行 cc -o main main.c,然后運(yùn)行 ./main 查看結(jié)果。 ?

      4. 實(shí)際上,這是“混合重置”?!败浿刂谩保ㄊ褂?git reset --soft 完成)將暫存更改,因此你無(wú)需再次 git add 添加它們,并且可以一次性提交所有更改。這不是我們想要的。我們希望選擇性地暫存部分更改,以拆分提交。 ?

      5. 實(shí)際上,這取決于上游分支本身是否已變基或刪除/壓扁了某些提交。git pull --rebase 嘗試通過(guò)在 git rebasegit merge-base 中使用 “復(fù)刻點(diǎn)fork-point” 機(jī)制來(lái)從這種情況中恢復(fù),以避免變基非本地提交。 ?

      6. 實(shí)際上,這取決于 Git 的版本。直到 2.26.0 版,默認(rèn)的非交互行為以前與交互行為稍有不同,這種方式通常并不重要。  ?

      感謝各位的閱讀!關(guān)于“怎么用Git變基來(lái)改變歷史”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!


      文章名稱:怎么用Git變基來(lái)改變歷史
      瀏覽地址:http://ef60e0e.cn/article/pogise.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        大姚县| 夹江县| 泰安市| 九龙县| 马尔康县| 阿克苏市| 阿拉善右旗| 获嘉县| 时尚| 晋江市| 佛学| 屏南县| 抚远县| 大竹县| 比如县| 华宁县| 浠水县| 宝山区| 玛曲县| 宜春市| 昂仁县| 古浪县| 安乡县| 阜新| 云和县| 海南省| 彝良县| 满城县| 清河县| 江阴市| 大洼县| 浮梁县| 彰武县| 中宁县| 沈丘县| 尼木县| 台南市| 滨州市| 金门县| 阿拉尔市| 宜君县|