# Log & Diff

## 기록확인(log)

**log**는 **역사**라 생각하면 된다. `commit`했던 버전들의 기록을 확인 할 수 있다.

```
$ git log
commit c6ce442fa11b976aa717eeacd4dc05a501bfdda5
Author: dahye Jeong <wjdekgp1750@naver.com>
Date:   Thu Mar 23 17:28:55 2017 +0900

    first commit

    첫 커밋임!!
```

commit 뒤의 문자(c6ce442fa11b976aa717eeacd4dc05a501bfdda5)는 이 버전에 대한 식별자(hashcode)이다.

```
$ git log -p
commit c6ce442fa11b976aa717eeacd4dc05a501bfdda5
Author: dahye Jeong <wjdekgp1750@naver.com>
Date:   Thu Mar 23 17:28:55 2017 +0900

    first commit

    첫 커밋임!!

diff --git a/test1.html b/test1.html
new file mode 100644
index 0000000..58d93db
--- /dev/null
+++ b/test1.html
@@ -0,0 +1 @@
+<p>test</p>
```

어떠한 코드가 바꼈는지 알 수 있다.

## 비교(diff)

### Unstage(uncommit)된 수정사항 확인

```
$ git diff
```

### commit(stage)된 수정사항 확인

```
$ git diff --cached
```

```
$ git diff --staged
```

### 브랜치간 비교

```
$ git diff [브랜치1] [브랜치2]
```

```
git diff master practice
diff --git a/aa.txt b/aa.txt
index ec18514..4374318 100644
--- a/aa.txt
+++ b/aa.txt
@@ -1,5 +1,3 @@
 first commit

-log,diff비교해보자!!
-
-master브랜치야
\ No newline at end of file
+log,diff비교해보자!!
\ No newline at end of file
```

### commit간 비교

```
$ git diff <commit hash> <commit hash>
```

```
$  git diff 59f62dfcb5742b3712f4e2a20c7e2b41e995fef9 cbba34b0b53696b22e8bf24894755431eaf2f525
diff --git a/aa.txt b/aa.txt
index ec18514..4374318 100644
--- a/aa.txt
+++ b/aa.txt
@@ -1,5 +1,3 @@
 first commit

-log,diff비교해보자!!
-
-master브랜치야
\ No newline at end of file
+log,diff비교해보자!!
```

### 마지막 commit 과 그 전 commit 비교

```
$ git diff HEAD HEAD^
```

달라진 부분을 알려준다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dahye-jeong.gitbook.io/til/git/2019-01-09-git-log.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
