Loading...
Loading...
Compare original and translation side by side
git add -pgit add -igit add -pgit add -igit status # See which files have changes
git diff --no-ext-diff # See all unstaged changes
git diff --cached --no-ext-diff # See already-staged changesgit add <file>git addgit status # 查看哪些文件有改动
git diff --no-ext-diff # 查看所有未暂存的变更
git diff --cached --no-ext-diff # 查看已暂存的变更git add <file>git addgit add -pgit add -pecho "y"yesecho "y"yesgit apply --cachedgit apply --cachedtmp//tmpmkdir -p tmptmp//tmpmkdir -p tmpgit add <file>git add <file>git diff <file> > tmp/full.patchgit apply --cached tmp/selected.patchgit diff <file> > tmp/full.patchgit apply --cached tmp/selected.patchgit diff <file> > tmp/full.patch@@+-- @@ -X,Y +X,Z @@git apply --cached tmp/selected.patchgit diff <file> > tmp/full.patch@@+-- @@ -X,Y +X,Z @@git apply --cached tmp/selected.patchdiff --git a/file.txt b/file.txt
index abc123..def456 100644
--- a/file.txt
+++ b/file.txt
@@ -10,6 +10,8 @@ optional context label
context line (unchanged)
-removed line
+added line
context line (unchanged)diff --git a/file.txt b/file.txt
index abc123..def456 100644
--- a/file.txt
+++ b/file.txt
@@ -10,6 +10,8 @@ optional context label
context line (unchanged)
-removed line
+added line
context line (unchanged)@@ -START,COUNT +START,COUNT @@@@ -START,COUNT +START,COUNT @@ -+ -+undefinedundefined
The patch might look like:
```diff
diff --git a/myfile.py b/myfile.py
index abc123..def456 100644
--- a/myfile.py
+++ b/myfile.py
@@ -5,6 +5,7 @@ import os
def foo():
pass
+ # Added comment in first hunk
def bar():
@@ -20,6 +21,7 @@ def bar():
def baz():
pass
+ # Added comment in second hunkdiff --git a/myfile.py b/myfile.py
index abc123..def456 100644
--- a/myfile.py
+++ b/myfile.py
@@ -20,6 +21,7 @@ def bar():
def baz():
pass
+ # Added comment in second hunkgit apply --cached tmp/second-hunk.patch
补丁内容可能如下:
```diff
diff --git a/myfile.py b/myfile.py
index abc123..def456 100644
--- a/myfile.py
+++ b/myfile.py
@@ -5,6 +5,7 @@ import os
def foo():
pass
+ # Added comment in first hunk
def bar():
@@ -20,6 +21,7 @@ def bar():
def baz():
pass
+ # Added comment in second hunkdiff --git a/myfile.py b/myfile.py
index abc123..def456 100644
--- a/myfile.py
+++ b/myfile.py
@@ -20,6 +21,7 @@ def bar():
def baz():
pass
+ # Added comment in second hunkgit apply --cached tmp/second-hunk.patch@@ -10,4 +10,7 @@
existing line
+line I want to stage
+line I do NOT want to stage
+another line I want to stage
more context@@ -10,4 +10,6 @@
existing line
+line I want to stage
+another line I want to stage
more context+10,7+10,6@@ -10,4 +10,7 @@
existing line
+line I want to stage
+line I do NOT want to stage
+another line I want to stage
more context@@ -10,4 +10,6 @@
existing line
+line I want to stage
+another line I want to stage
more context+10,7+10,6git diff --cached # Show staged changes
git diff # Show unstaged changes (should include excluded hunks)
git status # Overview of staged/unstaged stategit diff --cached # 查看已暂存的变更
git diff # 查看未暂存的变更(应该包含被排除的hunk)
git status # 暂存/未暂存状态概览@@git apply\ No newline at end of fileindex abc123..def456git apply --cached@@git apply\ No newline at end of filegit apply --cachedindex abc123..def456git apply --cached--cachedgit apply --check tmp/selected.patchgit apply --cached -v tmp/selected.patchdiff --git---/+++git apply --cached--cachedgit apply --check tmp/selected.patchgit apply --cached -v tmp/selected.patchdiff --git---/+++