$mkdir testrepo2
$cd testrepo2/
$git init .
Initialized Git repo in ~/testrepo2/.git/ $echo "Initial README." >> README
$git add .
$git commit -m "Initial Commit."
[master cdfdce7] Initial Commit. 1 file changed, 1 insertion(+) create mode 100644 README $
$echo -e "この行を追加したい\n\n\nInitial README." > README
$echo -e "\n\nこの行を追加したくない" >> README
$git diff
--- a/README +++ b/README @@ -1 +1,7 @@ +この行を追加したい + + Initial README. + + +この行を追加したくない
$ git add --patch README
@@ -1 +1,4 @@
+この行を追加したい
+
+
Initial README.
Stage this hunk [y,n,q,a,d]? yes
@@ -1 +4,4 @@ Initial README. + + +この行を追加したくない Stage this hunk [y,n,q,a,d]? no $
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README
#
# Changes not staged for commit:
# (use "git add <file>..." to update files to commit)
# (use "git checkout -- <file>..." to discard changes)
#
# modified: README
$
$ git diff --cached
diff --git a/README b/README
index 96f0a4b..af358b0 100644
--- a/README
+++ b/README
@@ -1 +1,4 @@
+この行を追加したい
+
+
Initial README.
$
$ git diff
diff --git a/README b/README
index af358b0..4be3cac 100644
--- a/README
+++ b/README
@@ -2,3 +2,6 @@
Initial README.
+
+
+この行を追加したくない
$
$git commit -m "Commit first line."
[master 8c5733b] Commit first line. 1 file changed, 3 insertions(+) $git status
# On branch master # Changes not staged for commit: # (use "git add <file>..." to add file to be committed) # (use "git checkout -- <file>..." to discard changes) # # modified: README $
$ git diff
diff --git a/README b/README
index af358b0..4be3cac 100644
--- a/README
+++ b/README
@@ -2,3 +2,6 @@
Initial README.
+
+
+この行を追加したくない
$
$ git add --patch
$ git checkout --patch
$ git diff --cached
$ git config color.ui auto
Use a spacebar or arrow keys to navigate