2011년 8월 22일 월요일

How to use 'git diff' on specific commit

Sometimes we might need to create 'diff' file for specific commit(s) and forward it to reviewers.
I also sometimes don't understand why they let me do it because they can but I understand there are a lot of patches for them to review.

Anyway, this is very simple to achieve it.
We just need to know commit-id on each patch.
We can use 'git log' for that.

For example, git shows patches like below when we type 'git log'.
$ git log
+++
commit commit-id1
Author Someone
Date Someday
Blur...blur..

commit commit-id2
Author Someone
Date Someday
Blur...blur..

...
+++

If we want to know diffs on commit-id1, we can do like below.
$ git diff commit-id1 commit-id2
In some cases, we can extract diffs to a file like below.
$ git diff commit-id1 commit-id2 > diff.txt

Hope this helps you.

댓글 없음:

댓글 쓰기