Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git入门ABC(大纲) #4

Open
chenkan opened this issue Jul 27, 2013 · 4 comments
Open

Git入门ABC(大纲) #4

chenkan opened this issue Jul 27, 2013 · 4 comments

Comments

@chenkan
Copy link
Owner

chenkan commented Jul 27, 2013

GIT - The Brief Introduction

GIT入门ABC

What is GIT?

  • 当前最流行的分布式版本控制系统
  • 轻巧而强大的分支控制

Some Basic Commands

注意GIT的分布式特性以及与SVN的对比

  • clone =~ svn checkout such as git clone https://github.com/chenkan/Demo.git
  • status is a smart command, such as git status
  • add such as git add <filename> (here a concept: stage/index)
  • commit such as git commit <filename> -m 'this is a msg'
  • push =~ svn commit such as git push
  • pull / fetch =~ svn up

拓展阅读

  • git status详解
  • pullfetch详解

Branch Control

分支控制算是GIT的必杀技,在GIT中分支创建和管理的成本几乎为零

大量使用分支进行开发是GIT的特色及优势所在

What is GIT's Branch?

《ProGit》书曰

  • Git中的分支,其实本质上仅仅是个指向commit对象的可变指针
  • 那么,Git又是如何创建一个新的分支的呢?答案很简单,创建一个新的分支指针

Some Branch Commands

  • git branch -a : 显示所有分支
  • git checkout -b myfeature dev : 基于dev分支创建一个新分支
  • git merge --no-ff myfeature : 将完成开发的分支merge回来
  • git checkout -b remote_branch origin/remote_branch : 切换至指定资源库分支进行工作
  • git checkout remote_branch : 效果等同于上一句命令
  • git push -u origin local_created_branch : 将本地创建的分支推送至资源库
  • git stash : 暂存当前工作内容

拓展阅读

  • mergerebase详解及对比

GIT Flow

一些开发模型与方式

  • GIT标准开发模型(http://www.oschina.net/translate/a-successful-git-branching-model
  • 本地小分支开发(讨论)
  • 前后端联调开发(讨论)

Demo with Eclipse

插件 : Egit

基本上与SVN操作很类似,假设不涉及分支操作,相似度可达95%

GIT Tools

托管服务器

  • github
  • gitlab
  • gerrit

命令行工具

  • zsh - Mac/Linux
  • PowerShell + posh-git - Windows

Reference

  • 《pro git》前三章 - 基础知识,建议认真阅读
  • http://robbinfan.com/blog/34/git-common-command - 推荐打印出来,随手可查
  • http://marklodato.github.io/visual-git-guide/index-zh-cn.html?no-svg

THE END

拥抱变化 拥抱GIT

改变工具 改变流程

@chenkan
Copy link
Owner Author

chenkan commented Jul 30, 2013

git log --graph --all --decorate

@chenkan
Copy link
Owner Author

chenkan commented Jul 30, 2013

git log --pretty=format:"%Cblue%ad %Creset%ae %Cgreen%s %Creset" --date=short -20

@chenkan
Copy link
Owner Author

chenkan commented Jul 30, 2013

@chenkan
Copy link
Owner Author

chenkan commented Jul 30, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant