GIT 介绍

Git

Introduction

摘要(Summary)

  1. 什么(What)
  2. 实战(How - In action)
  3. 基本命令(How - Basic commands)
  4. 为什么(Why)
  5. 最佳实践(Best practice)
  6. 参考资料

git [ ɡɪt ]饭桶,无用的人 http://www.iciba.com/git

什么(What)-1

Git (/ɡɪt/) is a widely used source code management system for software development. It is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. Git was initially designed and developed in 2005 by Linux kernel developers (including Linus Torvalds) for Linux kernel development.
-- https://en.wikipedia.org/wiki/Git_(software) Shower logo

什么(What)-2

Shower logo

In action 0 - 安装 -1

In action 0 - 安装-2

安装后检查: git --version

2016.02.25时最新版本:2.7.2

ref: http://git-scm.com/book/en/v2/Getting-Started-Installing-Git

In action 1 - 配置

    
        $ git config --global user.name "John Doe" 
            
        $ git config --global user.email johndoe@example.com
        
        

以Linux命令行操作为例

In action 2 - 搭窝

建库

克隆 git lab

克隆 git hub

git clone git@gitlab.com:hsDNA/sandbox.git

Shower logo

In action 3 - 填加文件/获取最新版本

git add (to stage)

git commit (to snapshot)

git push (to remote repository)

git pull (get the most fresh copy from the remote)

常用命令 - 日常使用

不常用命令 - 偶尔使用

为什么(Why)

以前的VCS

Shower logo

--everything-is-local

为什么(Why special)

Stage/Snapshot

Shower logo

--everything-is-local

为什么(Why special)-2 分布式

Shower logo

最佳实践(Best practice)-1 合作流程

中心式

Shower logo

最佳实践(Best practice)-2 注释


            <type>(<scope>):<subject>
            
<body>
<footer>

最佳实践(Best practice)-2.1 注释示例一


            Fix:(前台UI): 去掉登录页面上的多余功能
            
登录页面上的注册与修改密码两个功能不能使用,目前也用上不。去掉。
登录界面不再显示这两个功能。(此处信息用于测试验证用)

最佳实践(Best practice)-2 注释续:<type>

feat new feature for the user, not a new feature for build script
fix bug fix for the user, not a fix to a build script
docs changes to the documentation
style formatting, missing semi colons, etc; no production code change
refactor refactoring production code, eg. renaming a variable
test adding missing tests, refactoring tests; no production code change
chore updating grunt tasks etc; no production code change

最佳实践(Best practice)-3 .gitignore

gitignore - Specifies intentionally untracked files to ignore

Files already tracked by Git are not affected;

Each line in a gitignore file specifies a pattern

https://git-scm.com/docs/gitignore

最佳实践(Best practice)-3 .gitignore续

https://github.com/github/gitignore
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

休息
休息一会儿

push

EBKAC

相关链接

  1. 官方网站
  2. 维基百科
  3. Dumm教程(@viathink-非公开内容)
  4. 简单指南(the simple guide)
  5. 详细教程
  6. 详细的教程二
  7. git@viathink wiki(@viathink-非公开内容)
  8. karma(Commit Msg)

谢谢!