|
http://jonas.iki.fi/git_guides/ The Git Guides http://wiki.laptop.org/go/Git_Tips git技巧集
http://marc.info/?l=git 有很多git相关的问答
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html 用户手册
http://git.or.cz/gitwiki/GitTips Git小技巧
http://utsl.gen.nz/talks/git-svn/intro.html#feature-branches git-svn好资料
http://bazaar-vcs.org/BzrVsGit Bzr与Git的比较
http://www.dont-panic.cc/capi/?s=git
为什么说 Git 将取代 SVN 做软件版本控制? http://www.javaeye.com/news/4503-tortoisegit-windows-user-to-use-git tortoisegit: Windows用户使用Git的福音
http://rubynroll.javaeye.com/blog/203133
SVN+GIT=鱼与熊掌兼得http://docs.google.com/View?id=dfwthj68_675gz3bw8kj Git 魔法 [文章推荐]Comparison of revision control softwarehttp://en.wikipedia.org/wiki/Comparison_of_revision_control_software$ git commit --amend http://cworth.org/hgbook-git/tour/ 中有介绍,
好像是可修改前一次提交的msg
$ git stash save "some message" 当遇到一个小BUG但又不想马上解决,要等到你过段时间才解决的时候
$ git stash list
$ git stash apply [--index] [] (恢复状态)
$ git stash clear (clear all)
$ git stash drop [stash ] (clean one)
$ git stash pop [stash ] (clean one and apply)
[am = apply mail]
$ git am -3 patches.mbox
$ git fetch origin todo:my-todo-work
$ git fetch git://example.com/proj.git master:example-master
从origin仓库中将提取出来的master分支放到新创建的example-master分支中,相当于新建一个分支代替master
$ git count-objectsRecovering from repository corruption$ git-fsck --full
$ git log SHA1 --> SHA1 只要hexdig的前6-8个就行了
7.错误提交了commit怎么办?
a) git-revert
这个本身就会产生一个commit,如果用得多了会让你的log看起来不那么干净。;-)
b) git-reset
用这个要当心,它会把那个commit之后的commit全部删除。一个好的办法是:先建立一个临时的分支,然后再git-reset,再git-rebase,最后再删除临时的分支。 详细可以看这里。
$ git commit --amend 修订上一次提交的msg $ git commit -s --amend
< >-s, --signoff add Signed-off-by: header
--amend amend previous commitHow to change commits deeper in historygit rebase --onto .
git filter-branch can also be usefull. It has been ported from the obsoleted Cogito's .How to get only merges in gitk?gitk --full-history -- a//b
What to do if you have realized that you are on wrong branch?git checkout -m -m merge local modifications into the new branchRecovering lost changes
$ git log master@{1}
$ git show master@{2} # See where the branch pointed 2,
$ git show master@{3} # 3, ... changes ago.
$ gitk master@{yesterday} # See where it pointed yesterday,
$ gitk master@{"1 week ago"} # ... or last week
$ git log --walk-reflogs master # show reflog entries for master
$ git show HEAD@{"1 week ago"} #=======================================================================
在工作目录下修改 .gitignore 来ingore一些文件 如 src/*.bak tmp/*
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
git config --global branch.autosetupmerge auto
git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com
git apply patch -p0 相当于打补丁 git-format-patch 生成补丁
git pull svn update
git-revert(1) to undo botched commits. 与svn的revert不同,如想达到svn效果用 reset
$ git-checkout -f foo.c 这招强制覆盖
$ git fetch /home/bob/myrepo master:bob-incoming
这个命令将 Bob 的 master 分支的导入到名为 bob-incoming 的分支中( 不同于 git-pull 命令,git-fetch 命令只是取得 Bob 的开发工作的拷贝, 而不是合并经来)。接着:
$ git whatchanged -p master..bob-incoming $ git repack 打包 $ git prune-packed 清除已打包后多余的东东 对比查看.git/object目录下的内容 find .git/objects -type f
$ git branch -D branch-name (delete branch)
$ git whatchanged
$ git checkout -b new v2.6.13 从v2.6.13版出中创建一个new分支开始work
$ git branch -r 其中-r 是remote的意思,如果带有 -d xx表示删除远程的branch
$ git checkout -b my-todo-copy origin/todo
Note that the name "origin" is just the name that git uses by default to refer to the repository that you cloned from.
$ git add -X "*.bak" . $ git show HEAD^:path/to/file
$ git am --resolved
$ git clone --bare ~/proj proj.git 制作共享仓库
$ touch proj.git/git-daemon-export-okExporting a git repository via http$ mv proj.git /home/you/public_html/proj.git
$ cd proj.git
$ git --bare update-server-info
$ chmod a+x hooks/post-update
$ git push ssh://yourserver.com/~you/proj.git master:master
$ cat >>.git/config reset --hard HEAD@{1}
man git-rev-parse会有树状的图表示 isa-^n 表示回退n isa~n 中的n表示n个 ^1 , ^HEAD 表示排除
git-fetch -v 相当于update远程数据到本地来,相当于svn update --> git-pull 才更新数据到本地,才发现对比有数据变更,还要再学学
git-log --color git-branch --color
git-branch $USER/work 可以生成像目录树一样的branch ,也可以同样方法生成tag, git-tag $USER/mytag , 在生成 brahcn or tag可以 branch mybranch master^2 ==>表示基于master^2来生成分支,同理可用于tag
git fetch origin --> origin表示远程clone的仓库, git-merge origin/master 表示将远程的master分支内容merge到本地当前分支, 另一招 git-branch foobar origin/foobar $git-checkout foobar就相当于origin/foobar,方便
git-push origin myLocalBranch:RemoteExistBranch 提交, 如果已创建了tags的话可以$git-push --tags origin
$git-push origin :refs/heads/ 在本地仓库向远程创建一个新分支, :refs这种语法采用 .git/refs目录这种结构
git-push origin : 清除远程分支,注意,前面的: 前没有是空的 , $git-push origin :refs/tags/清tag
清理 $git-remote prune $git-branch -d (delete) -r (remote) 清掉远程的RemoteBranch分支
git-checkout -b work 自动创建一个work分支并checkout过去
$git-whatchanged -p $git-checkout HEAD~7 foobar.c $git-show HEAD~7:foobar.c >foobar~7.c
git-format-patch 生成补丁,默认用的是-2 ,可以设置为-3
$git-stash 很有用,
$git-repack $git-prune $git-gc --prune --aggressive 清查仓库
git checkout -m
git rebase --onto
比较两个本地仓库GIT_ALTERNATE_OBJECT_DIRECTORIES=../repo/.git/objects git-diff-tree $(GIT_DIR=../repo/.git git rev-parse --verify HEAD) HEAD
方法2:GIT_ALTERNATE_OBJECT_DIRECTORIES=../repo/.git/objects cg-diff -r `GIT_DIR=../repo/.git cg-object-id -c HEAD`..HEAD
How to remove all files which are missing from working directory?$git ls-files -z --deleted | git update-index -z --remove --stdin$ git ls-files -o --exclude-standard >> .gitignore
$ cat >>.git/config |
|
|