Git을 이용해서 차이점을 살펴 보기

 

Git을 이용해서 변경사항을 추적하는 일은 다음과 같다.

1) Git은 작업트리의 변경사항

2) 스테이징 되어서 커밋하려는 변경 사항

3) 저장소간의 차이점을 보여주는 사항

 

매개변수 없이 git diff를 실행하면 아직 스테이징되지 않고 커밋되지도 않은

작업트리(작업 디렉터리)의 변경사항을 보여준다.

 

>git diff

root@ubuntu:/work_remotGitHub/mysite-remote# git diff
diff --git a/index.html b/index.html
index ca86894..06bfc3d 100644
--- a/index.html
+++ b/index.html
@@ -7,6 +7,7 @@
     <h1>Hello World!</h1>
     <ul>
         <li><a href="about.html">About</a></li>
-    </ul>
+                 <li><a href="contact.html">Contact</a></li>
+       </ul>
 </body>
 </html>

 

git diff를 매개변수 없이 실행하면 작업 트리의 변경 사항과 스테이징 영역을 비교 한다.

 

스테이징 영역과 저장소의 차이점을 알기 위해서는 아래를 실행 한다.

root@ubuntu:/work_remotGitHub/mysite-remote# git diff --cached
diff --git a/index.html b/index.html
index e812d0a..ca86894 100644
--- a/index.html
+++ b/index.html
@@ -6,7 +6,7 @@
 <body>
     <h1>Hello World!</h1>
     <ul>
-        <li><a href="bio.html">Biography</a></li>
+        <li><a href="about.html">About</a></li>
     </ul>
 </body>
 </html>

 

스테이징 한것은 <li><a href="about.html">About</a></li> 이기 때문에 이부분에 대해서만 결과가 나오는 것을 알 수 있다.

 

작업트리(작업디렉터리), 스테이징 영역, 저장소(repository) 3곳 모두에서의 모든 차이점을 보고 싶다면 HEAD 매개변수를 추가한다.

root@ubuntu:/work_remotGitHub/mysite-remote# git diff HEAD
diff --git a/index.html b/index.html
index e812d0a..06bfc3d 100644
--- a/index.html
+++ b/index.html
@@ -6,7 +6,8 @@
 <body>
     <h1>Hello World!</h1>
     <ul>
-        <li><a href="bio.html">Biography</a></li>
-    </ul>
+        <li><a href="about.html">About</a></li>
+                 <li><a href="contact.html">Contact</a></li>
+       </ul>

 </body>
 </html>

 

HEAD는 현재 작업중인 브랜치에서 가장 최신의 커밋을 나타내는 키워드다.

 

commit -a 해서 변견이력을 등록 한다. 메시지는 각자 알아서 상세히 기록 하자.

 

 

+ Recent posts