git add -p
을 사용하여 코드 변경 사항을 여러 커밋으로 분할했습니다. 그러나 그 후 git commit
을 수행하면 커밋되지 않은 것들을 포함하여 모두 변경됩니다. 나는 SO에 관한 몇 가지 질문을 보았지만 명백한 실수는 발견 할 수 없었다. 내가 뭘 잘못하고 있는지 이해할 수있게 도와 주실 수 있겠습니까? 아래는 제가 시도한 명령과 그 결과입니다.git commit은 unstaged hunks를 커밋합니다.
bash-3.2$ git diff test11.txt
diff --git a/test11.txt b/test11.txt
index f077274..e811cae 100644
--- a/test11.txt
+++ b/test11.txt
@@ -1,5 +1,5 @@
-Hello
-World
+hello
+world
-Blahblahblah
-blah
+blahblahblah
+Blah
bash-3.2$ git add -p test11.txt
diff --git a/test11.txt b/test11.txt
index f077274..e811cae 100644
--- a/test11.txt
+++ b/test11.txt
@@ -1,5 +1,5 @@
-Hello
-World
+hello
+world
-Blahblahblah
-blah
+blahblahblah
+Blah
Stage this hunk [y,n,q,a,d,/,s,e,?]? s
Split into 2 hunks.
@@ -1,3 +1,3 @@
-Hello
-World
+hello
+world
Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? y
@@ -3,3 +3,3 @@
-Blahblahblah
-blah
+blahblahblah
+Blah
Stage this hunk [y,n,q,a,d,/,K,g,e,?]? n
bash-3.2$ git status
# On branch test
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: test11.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: test11.txt
bash-3.2$ git commit test11.txt
[test 1b85189] Test12
1 files changed, 4 insertions(+), 4 deletions(-)
bash-3.2$ git status
# On branch test
nothing added to commit
감사를 기록 할 수 있습니다. 이것은 내 문제를 해결하는 데 도움이됩니다. 내가 여러 파일을 상연했기 때문에이 방법을 시도했지만, 모든 파일을 한 번에 커밋하고 싶지 않았기 때문에이 방법을 시도했습니다. 이 경우에는 파일을 한 번에 하나씩 추가/커밋하는 것이 가장 좋습니다. –
예, 기본적으로 준비 영역을 사용하여 커밋 내용을 구성한 다음 준비된 내용을 커밋합니다. 린스하고 반복하십시오. – Amber