Skip to content
rd084c edited this page Apr 14, 2014 · 10 revisions

为了让公司内部的开发人员迅速了解如何使用git以及github 常用操作列举如下(以git@github.com:iTianchuang/cookbook.git为例):

如何准备工作区

git clone git@github.com:iTianchuang/cookbook.git

检查各种状态

  1. 检查工作区状态 git status
  2. 检查某次提交 git show COMMIT
  3. 比较某个文件 (工作区和待提交区) git diff file

常用工作循环

  1. 添加文件到准备区 git add file
  2. 提及变更 git commit -m "comments here."
  3. 与github上进行同步 git pull
  4. 推送到github git push

查询被删除的文件

git log --diff-filter=D --summary

恢复某个被删除的文件

git checkout COMMIT^ -- file

如何使在windows上使用用BeyondCompare3作为文件比较工具

vi ~/.gitconfig

[diff] 
tool = bc3
[difftool "bc3"]
cmd = \"E:/PortApps/Beyond Compare 3/bcomp.exe\" -expandall -solo \"$LOCAL\" \"$REMOTE\”

配置好后利用工具对比单个或多个文件,手动同步。

git difftool