顯示具有 diff 標籤的文章。 顯示所有文章
顯示具有 diff 標籤的文章。 顯示所有文章

2013年11月5日 星期二

看某一個 commit 的 diff

只要看某一個 commit 的 diff,就用
$ git show 2e6f1155dd56512d5f848f4b7e6198c38aa256f2

2011年6月8日 星期三

diff , ignore white space

如果有人改了 white space 的數量,或是以 white space 來代替 tab, diff 的結果就會一團亂。

這時候可以下
git diff -w
來忽略 white space.

如果是在 difftool 模式 (invoke vimdiff),就要在 vi 裡下 command:
:set diffopt+=iwhite



ref: http://stackoverflow.com/questions/1265410/is-there-a-way-to-configure-vimdiff-to-ignore-all-whitespaces

ref: http://myvicommandhelp.blogspot.com/2011/06/diff-ignore-white-space.html

2011年5月15日 星期日

format-patch & am

在作 rebase, merge 的時後,fail 得太嚴重。所以希望手動來作。
手動作 rebase.. 好確保每個 commit 一一個上去。

可以用git format-patch 'rev-name'產生一堆從 'rev-name' 開始的patch , 一個 commit,一個 patch。

有這些patch檔,就可以用git am 'patch-filename'一個一個上回去。
這樣產生的 patch file 和 am 後的 rev ,會把 commit log 也保留住。

如果一次要全上,可以用: git am *.patch
會自動依照 001, 0002. 003 的順序 patch .

format-patch 可以加 option '-3' 表示 只要該rev 後的三個 patch



ref:
http://gitready.com/intermediate/2009/03/04/pick-out-individual-commits.html

2011年4月13日 星期三

config merge tool

$git config --global merge.tool vimtool
這樣開啟 .gitconfig: 會多了:
[merge]
tool = vimdiff

2011年3月23日 星期三

internal -- staging area

這一篇說得很清楚 (http://ihower.tw/blog/archives/2591 ).

staging area 是一塊 git 用來紀錄 commit command 要"提交的東西" 的區域)。
所以當你commit 過後,staging area 是空的。
用 git add, 就會把 add 的 file 加到 staging area 裡。

平時用的
$git commit -a a option ,意指..將修改過的檔案add 到 staging area,
所以這樣 commit ,會自動把修改過的 file commit 進去。

要是不加 -a 選項,就要在commit 之前,用 git add 把要 commit 的 file 加到 staging area。
然後 commit 才會 commit這些 file 進去。

要把 staging area 裡的 file 拿出來,用:
$git reset HEAD filename
這樣,那個 file 就會從 staging area 移出來,恢復到還沒被加入 staging area 的狀態 (原來是 untracked 就是 untracked, 是unstaging 就是 unstaging),修改的內容不會消失。

因為有 staging area,所以 diff 分為以下三種:
$git diff
比較 working 跟 staging area

$git diff --cached
拿staging area 的file 跟 HEAD 的內容 (上次commit)比較

$git diff HEAD
比較 working 跟 HEAD 的不同。

2011年3月17日 星期四

diff - show brief

只是要看有哪些檔案不一樣,可以加上 --stat 這個選項
$ git diff 201101270-a2 --stat
這樣就會顯示和 20110127-a2 這個 branch 的差異:
Makefile | 1 +
board/freescale/mx51_bbg/flash_header.S | 24 ++++--
board/freescale/mx51_bbg/lowlevel_init.S | 5 +-
board/freescale/mx51_bbg/mx51_bbg.c | 118 +++++++++++++++++++++++++++---
include/configs/mx51_bbg_android.h | 8 ++-
5 files changed, 132 insertions(+), 24 deletions(-)