1) how to show more detail with git log?
git log --stat
commit 211c9b596d5abb589138e5f5ba81f1eb6958bb17
Author: wangeen <[email protected]>
Date: Tue Apr 29 16:16:18 2014 +0800
update run script
mysite/run.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
2) how to understand branch in git?
如果没有branch,commits将会永远只能保持链状结构,现在加入了branch,整个commits将会变成树形结构,树形结构让并行开发变成可能。所以branch的本质就commit上面多了一个指针。在这里我们要舍弃svn中类似trunk的概念,所有的开发都是在branch上,没有必要把所有的branch都弄一样了,每个branch就应该保持不同。
3) How can you get the tree-like view of commits in terminal?
A solution is to create an Alias in your .gitconfig
and call it easily
[alias] tree = log --graph --decorate --pretty=oneline --abbrev-commit
And when you'll call it next time, u'll use
git tree
4) branch的基本操作
create branch: git branch my_branch_name HEAD~2
list branch: git branch
switch branch: git checkout branch_name
5) tag 的基本操作
http://git-scm.com/book/en/Git-Basics-Tagging
创建一个tag:create tag: git tag -a v1.2 -m 'version 1.2' 9fceb02
tag不会默认push到remote,要用下面的命令
$ git push origin --tags
6) 如何把untracked file添加到ignore list?
首先声明一下untracked和ignore是两个完全不同的概念, untracked是没有处理过的文件,ignore是已经处理过的文件,只是处理的结果就是忽略它。把不需要的文件直接忽略有很多好处,做法也很简单就是建立一个ignore相关的文件,把要忽略的文件写进去就可以了,下面是一些更好的做法。
echo $(git status --porcelain | grep '^??' | cut -c4-) >>.gitignore
还有一种比较简单的做法
git status -u no
Reference List:
http://git-scm.com/book/en/Git-Basics-Viewing-the-Commit-History this is a good article for git log usage, it tell us some good options for git log, for example git log --stat, git log -p, git log --pretty=format:"%h" and so on. Also this website is book for git usage, you can read it more details.