更新:
您可以使用以下命令重現此問題:
mkdir test && cd test
git init
cat > sample <<EOD
:host {
max-width: 20%;
text-align: center;
cursor: pointer;
.svg-game-controller {
width: 100%;
EOD
git add -A
git commit -m 'first'
cat > sample <<EOD
@import '../svg-icon.scss';
:host {
@include svg-icon-default-style(20%);
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
height: 100%;
.svg-game-controller {
width: 100%;
EOD
git diff # check changes
git add -p # patch about diff
(interactive mode) s
(interactive mode) n # skip first hunk
# then you can see editing window.
我遇到了關于 git hunk 編輯的問題。
它可以通過修補硬分裂來解決,但我不想那樣,希望純粹了解 git。
請任何人向我描述正確的大塊編輯。
據我所知,在手動大塊編輯視窗中,
你可以像下面這樣檢查大塊頭資訊:
<sign><start line in edit window>,<changed line counts (signed line with sources)>
有兩部分是這樣的:@@ <delete change info> <add lines change info> @@
示例:
@@ -1,7 3,12 @@表示洗掉更改從編輯視窗的第一行開始,包含源內容的行為 7(除 signed liens 外的所有行)。
然后這是我的目標檔案。
diff --git a/src/app/svg-icon/logo-svg/logo-svg.component.scss b/src/app/svg-icon/logo-svg/logo-svg.component.scss
index c0f0c72..9500e10 100644
--- a/src/app/svg-icon/logo-svg/logo-svg.component.scss
b/src/app/svg-icon/logo-svg/logo-svg.component.scss
@@ -1,7 1,14 @@
@import '../svg-icon.scss';
:host {
- max-width: 20%;
- text-align: center;
- cursor: pointer;
@include svg-icon-default-style(20%);
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
height: 100%;
.svg-game-controller {
width: 100%;
首先,我把大塊頭分成兩部分。
然后先跳過并編輯第二部分。
diff --git a/src/app/svg-icon/logo-svg/logo-svg.component.scss b/src/app/svg-icon/logo-svg/logo-svg.component.scss
index c0f0c72..9500e10 100644
--- a/src/app/svg-icon/logo-svg/logo-svg.component.scss
b/src/app/svg-icon/logo-svg/logo-svg.component.scss
@@ -1,7 1,14 @@
@import '../svg-icon.scss';
:host {
- max-width: 20%;
- text-align: center;
- cursor: pointer;
@include svg-icon-default-style(20%);
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
height: 100%;
然后我洗掉了如下 7 行:
# Manual hunk edit mode -- see bottom for a quick guide.
@@ -1,7 3,12 @@
:host {
- max-width: 20%;
- text-align: center;
- cursor: pointer;
@include svg-icon-default-style(20%);
.svg-game-controller {
width: 100%;
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove ' ' lines, delete them.
# Lines starting with # will be removed.
#
# If the patch applies cleanly, the edited hunk will immediately be
# marked for staging.
# If it does not apply cleanly, you will be given an opportunity to
# edit again. If all lines of the hunk are removed, then the edit is
# aborted and the hunk is left unchanged.
我編輯為 -1,7 3,5 但出現錯誤。
(2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? e
error: patch failed: src/app/svg-icon/logo-svg/logo-svg.component.scss:1
error: src/app/svg-icon/logo-svg/logo-svg.component.scss: patch does not apply
我不明白為什么 git 會這樣作業
我怎樣才能成功獲得這個 HUNK 補丁?
uj5u.com熱心網友回復:
更新:這是以前版本的 git 錯誤(可以用 2.30.1 重現)
2.38.1 錯誤已修復
這更多的是評論而不是答案我無法制作干凈的評論緩沖版本所以:
首先,我把大塊頭分成兩部分。
然后先跳過并編輯第二部分。
然后我洗掉了如下 7 行:
[(deleting all additions below the `@include`)]
當我這樣做時,它起作用了。洗掉您不想提交的添加:x,它適用。我以以下結尾的作業編輯緩沖區:
# Manual hunk edit mode -- see bottom for a quick guide.
@@ -1,7 3,12 @@
:host {
- max-width: 20%;
- text-align: center;
- cursor: pointer;
@include svg-icon-default-style(20%);
.svg-game-controller {
width: 100%;
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove ' ' lines, delete them.
# Lines starting with # will be removed.
# If the patch applies cleanly, the edited hunk will immediately be marked for staging.
# If it does not apply cleanly, you will be given an opportunity to
# edit again. If all lines of the hunk are removed, then the edit is
# aborted and the hunk is left unchanged.
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/534323.html
標籤:混帐
