Pragmatic Version Control Using Git(笔记)

Pragmatic Version Control Using Git

跳转到: 导航, 搜索
  1. git config --global user.name "Travis Swicegood"
  2. git config --global user.email "development@domain51.com"
  3. git config --global --list
  4. git config --global color.ui "auto"
  5. cd mysite && git init
  6. git commit -m "add in hello world HTML" //SHA1哈希
  7. git branch RB_1.0 master //创建分支
  8. git checkout RB_1.0 //??似乎没有到另外一个目录??我个人怀疑这样做的效率(不过,也许Linux的ext3文件链接处理起来比较方便?)
  9. git tag 1.0 RB_1.0 //tag:标记一个特殊的时间点。。。
  10. rebase:合并分支上的修改到主线
    1. git checkout master
    2. git rebase RB_1.0 //试图replay所有变更。。。
    3. git branch -d RB_1.0 //一旦合并到主线,则可以删除掉分支
    4. 但是,删除了分支后怎么恢复呢?可以从tag:git branch RB_1.0.1 1.0 这只是为了fix特定状态发布的补丁
  11. git log --pretty=oneline
  12. git archive --format=tar --prefix=mysite-1.0/ 1.0 | gzip > mysite-1.0.tar.gz
  13. git clone git://github.com/tswicegood/mysite.git mysite-remote //远程仓库
  14. git add -i //交互模式?
  15. git add -p //导出patch文件(这个比较赞,其他svn、hg都没见过这么方便的)
  16. 显示差异 (1)what's in your working tree, (2)what's staged and ready to be committed, and (3)what's in your repository:git diff |--cached|HEAD
  17. add .*.swp to the .gitignore ...
  18. 分支重命名:git branch -m old new
  19. One of the hardest parts of branches is figuring out when to create a branch. It’s an art, not a science
    1. Experimental changes
    2. New features
    3. Bug fixes
  20. checkout -b(创建新分支同时checkout)
  21. Merging:(注意,merge后还需要提交!)
    1. Straight merge:合并2个分支:在主线上执行git merge branch即可
    2. Squashed commits:压缩分支上的多个提交,转换为另一个上的单个提交(?),git merge --squash branch
    3. Cherry-picking:直接将一个分支上的一个提交送到另一个分支上(这个太酷了,mecurial好象不支持~~)git cherry-pick 321d76f(分支上的commit编号)
      1. -n选项:to do the merge but stop before creating a commit
  22. git reset --hard HEAD^
  23. 查看历史:git log(可以追加额外的参数指定范围,略)
  24. 追踪特定文件中行的变更情况:git blame -L 12,13 hello.html //注意:可以12,+2或13,-2描述(微型语法~~)
  25. revert:重写历史... Break one commit into multiple commits??
  26. git fetch:保持与远程仓库up-to-date
  27. git branch -r
  28. git push
  29. git diff:查看2个版本之间的修改情况(显示为一个差分提交,这个功能Mercurial/Hg是没有的,SVN可以做出比较),而git log将显示所有提交的历史
  30. Beyond the Basics(略):
    1. git gc:Compacting your repository history
    2. git archive:Exporting your repository
    3. git rebase:Rebasing a branch's history against its parent
    4. Using the reflog to fix your repository
    5. Bisecting your repository to find what change introduced a bug 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值