ありがとう、この質問を参照してください。変更が既にステージに追加されている間に別の変更をコミットするにはどうすればよいですか?
変更を自動的にコミットするスクリプトを作成しています。
ステージに何らかの変更が既に追加されている場合、指定されたファイルの指定された行だけをコミットする方法はありますか?例えば
、
私は空白hoge.txtを持っています。
次に、いくつかの行を追加してコミットします。
diff --git a/hoge.txt b/hoge.txt
index e69de29..b3c5a95 100644
--- a/hoge.txt
+++ b/hoge.txt
@@ -0,0 +1,5 @@
+line1
+line2
+line3
+line4
+line5
git status
こう述べています。そして、
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: hoge.txt
、私はいくつかの行に、よりLINE0とLINE6を追加します。
diff --git a/hoge.txt b/hoge.txt
index b3c5a95..6006aa3 100644
--- a/hoge.txt
+++ b/hoge.txt
@@ -1,5 +1,7 @@
+line0
line1
line2
line3
line4
line5
+line6
git status
言う:
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: hoge.txt
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: hoge.txt
、私は段階的な変更を加えることなく、段階的ではない変更をコミットしたいです。しかし、1行目から5行目までをステージングする必要があります。
git status
は言う:
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: hoge.txt
git diff --cached
は言う:あなたがすることはできません
diff --git a/hoge.txt b/hoge.txt
index 588aa45..6006aa3 100644
--- a/hoge.txt
+++ b/hoge.txt
@@ -1,2 +1,7 @@
line0
+line1
+line2
+line3
+line4
+line5
line6
OH ...ご回答いただきありがとうございます。 –