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

2013-02-19

[Git] 列出 commit 中的異動檔案

查看 commit 記錄

$ git show <commit>

但這樣沒辦法清楚列出到底是有哪些檔案有異動

只顯示異動的檔案,不顯示程式碼的話,請加上 --name-only 的參數

$ git show --name-only <commit>


要更進一步的只顯示檔案,連 commit 的相關資料也不要顯示的話

$ git show --pretty="format:" --name-only <commit>

以上,簡單的列出檔名

Reference:

git show - List all the files for a commit in Git - Stack Overflow

2010-12-20

[Git] 幫程式碼寫日記 - Git

Git logo

Linus:
"I'm an egotistical bastard, and I name all my projects after myself. First Linux, now git."

git 是一套分散式版本控制系統,由Junio Hamano 和 Linus Torvalds 開發,一開始是要用來取代非開源的 BitKeeper 分散式版本控制系統。
目前有非常多的專案都是用 git 在開發:
Git, Linux kernel, perl, Gnome, Ruby on Rails, Andruid, Facebook, jQuery......

我也是 Git 的新手,所以要我介紹 Git,不如看專家介紹來的實在!

關於 Git 神奇的地方:
我愛Git - Jserv: jserv.sayya.org/writing/loving-git.pdf
Why Git is Better Than X
Why Git is Better Than X(繁體中文)
Git @ wiki
gittutorial(7)
Git 版本控制系統 (1) - ihower


一些不錯的 Git 網站:
Pro Git - Pro Git Book
git ready
Git Magic - Preface

2010-12-07

[Git] 一些基本的環境設定 (2010/12/15 Update!)

使用 git 第一步是設定你的基本資料,也就是 user name 跟 user email

$ git config --global user.name "username"
$ git config --global user.email "username@email.com"

設定顯示顏色
$ git config --global color.diff auto
$ git config --global color.status auto
$ git config --global color.branch auto
$ git config --global color.log auto

設定會存在 ~/.gitconfig
或者可以下指令看
$ git config -l

自訂 log 格式到 lg,當然你也可以定義其他 alias
$ git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"


讓 Git 忽略特定檔案


使用者自行建立名為 .gitignore 的檔案
ex.
# 註解,會被忽略。
*.a       # 不要追蹤檔名為 .a 結尾的檔案
!lib.a    # 但是要追蹤 lib.a,即使上方已指定忽略所有的 .a 檔案
*.swp
*~

或是,只想要忽略當前的 repository 中的檔案
將檔案設定加到 .git/info/exclude 中就可以了

[Git] Start To Git

以 ubuntu 來說,要裝 Git
$ sudo apt-get install git-core
這樣就裝好了..結束!了嗎?

# 為專案新增 Git Repositiory


假設專案的資料夾為 project
$ cd project
$ git init

git 會 reply
Initialized empty Git repository in .git/
所有 repository 所需要的資料通通會在 project/.git/ 裡面

接著將 project 裡要讓 git 追蹤的檔案加入
$ git add .
(. 指目前所在目錄,當然也可以指定檔案)

git 會把 add 的檔案暫存起來

最後輸入 commit 指令,把資料 commit
$ git commit
輸入指令後會進入編輯器,為目前的資料變動加上說明
存檔後此次 commit 的資料就會加入 repository 中


官方網站跟手冊:
Git - the fast version control system
official Git tutorial : a good place to get started.
Everyday GIT : in 20 commands is good for a useful minimum set of commands.
Git User Manual