Git来了
Upcoming SlideShare
Loading in...5
×
 

Git来了

on

  • 520 views

这是个培训前的开胃菜

这是个培训前的开胃菜
更多欢迎加入 门户前端 团队工程组

Statistics

Views

Total Views
520
Views on SlideShare
492
Embed Views
28

Actions

Likes
0
Downloads
6
Comments
0

1 Embed 28

http://fenxiang.taobao.net 28

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Git来了 Git来了 Presentation Transcript

  • Git 来了 (上) Git培训系列 1
  • 目录• 引子• Git 简介• Git 基础使用• Tortoise Git 简介• GitHub 介绍 2
  • 从本质开始引子 3
  • 殊途同归的工程特点 4
  • 互联网软件技术特有特点• 大多数值得一做的工程都不会是之前的项 目的重复,而更具备发明性。 5
  • 我们如何应对?• 鼓励探索• 避免重复• 确保细节最佳(可能不是 最优)• 允许反悔• 以上过程尽可能 简单和便捷 6
  • 说好的代码呢?• ?? 7
  • 了解新的事物GIT 简介 8
  • Git ?• 诞生于2005年 (SVN 诞于 2001)• 分布式版本管理系统• 快照式数据存储• 新的分支模型(非线性开发)• 可以离线工作 9
  • 版本控制• 直接拷贝• 本地数据库管理• 集中化管理(SVN…)• 分布式管理(Git…) 10
  • 11
  • 本地化增量存储 集中化 分布式 本地化快照存储 集中化 分布式 12
  • 增量存储快照存储 13
  • 14
  • 15
  • 16
  • 17
  • Git 数据流概要 远程仓库 fetch push 本地仓库pull commit 索引(缓存) checkout HEAD add 工作 目录 18
  • 通过约定可以很强大 19
  • 常规开发 20
  • 微创新的行为 21
  • 热切换 22
  • 灵活的工作流程 开发者 开发者开发者 开发者 共享仓库开发者 开发者 开发者 开发者 中央仓库模型 23
  • 仲裁 官方仓库 副手副手开发者 开发者 开发者 开发者 “仲裁-副手”模型 24
  • 官方仓库 开发者公仓 开发者公仓整合管理员 开发者私仓 开发者私仓 整合管理员 模型 25
  • 正在使用 Git 的项目 26
  • 常用操作GIT VS SVN 27
  • 检出仓库 28
  • 提交改动 29
  • 推送更改 30
  • 更新仓库 31
  • 使用分支 32
  • 知其然,(知其所以然)GIT 基础使用 33
  • Git特性Snapshots, not Patches 要文件快照,不要补丁
  • Patches/补丁
  • Patches/补丁
  • Patches/补丁
  • Patches/补丁
  • Patches/补丁
  • Patches/补丁
  • Snapshots/快照
  • Snapshots/快照
  • Snapshots/快照
  • Snapshots/快照
  • Snapshots/快照
  • Snapshots/快照
  • Patches VS Snapshots
  • Patches VS Snapshots
  • Git基础操作Basic GitGit基础操作
  • Git基础操作First Steps
  • 全局配置$ git config --global user.name “temu.psc”$ git config --global user.email temu.psc@taobao.com$git config –list 查看配置信息
  • Git基础操作Getting a Repo 获取一个git仓库
  • Git基础操作Create One创建一个仓库
  • Git基础操作 git init$vim example.js$git init
  • Git基础操作$ find . ./.git/hooks/pre-commit.sample. ./.git/hooks/pre-rebase.sample./.git ./.git/hooks/prepare-commit-./.git/config msg.sample./.git/description ./.git/hooks/update.sample./.git/HEAD ./.git/info./.git/hooks ./.git/info/exclude./.git/hooks/applypatch-msg.sample ./.git/objects./.git/hooks/commit-msg.sample ./.git/objects/info./.git/hooks/post-commit.sample ./.git/objects/pack./.git/hooks/post-receive.sample ./.git/refs./.git/hooks/post-update.sample ./.git/refs/heads./.git/hooks/pre-applypatch.sample ./.git/refs/tags ./example.js
  • Git基础操作$vim example.js$git add .$git commit –m “first commit”
  • Git基础操作$ find . ./.git/info/exclude. ./.git/logs./.git ./.git/logs/HEAD./.git/COMMIT_EDITMSG ./.git/logs/refs./.git/config ./.git/logs/refs/heads./.git/description ./.git/logs/refs/heads/master./.git/HEAD ./.git/objects./.git/hooks ./.git/objects/1e./.git/hooks/applypatch-msg.sample ./.git/objects/1e/7dd2a82581302ae7cc19160baddcc9f0dbf379./.git/hooks/commit-msg.sample ./.git/objects/21./.git/hooks/post-commit.sample ./.git/objects/21/ea552f084548fe60ace44ffcb971f1b999be79./.git/hooks/post-receive.sample ./.git/objects/ee./.git/hooks/post-update.sample ./.git/objects/ee/13c25393814cfa2a0cefbba6dac3e730981ca2./.git/hooks/pre-applypatch.sample ./.git/objects/info./.git/hooks/pre-commit.sample ./.git/objects/pack./.git/hooks/pre-rebase.sample ./.git/refs./.git/hooks/prepare-commit-msg.sample ./.git/refs/heads./.git/hooks/update.sample ./.git/refs/heads/master./.git/index ./.git/refs/tags./.git/info ./example.js
  • Git基础操作Clone One克隆一个仓库
  • Git基础操作git clone
  • Git基础操作git clone git@github.com:maxbbn/rating-app.gitgit clone git://github.com/maxbbn/rating-app.git
  • Git基本工作流程A Basic Workflow 基本工作流程
  • Git基本工作流程 A Basic Workflow Edit files Stage the changesReview your changesCommit the changes
  • Git基本工作流程工作目录.git子文件夹
  • Git基本工作流程
  • Git基本工作流程
  • Git基本工作流程
  • Git基本工作流程 A Basic Workflow Edit files Stage the changesReview your changesCommit the changes
  • Git基本工作流程$vim example.jsConsole.log(“hello,temu.psc!”);=>(文件编辑)Console.log(“hello,longzang!”);
  • Git基本工作流程$ git status
  • Git基本工作流程$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in workingdirectory)## modified: example.js#no changes added to commit (use "git add" and/or "git commit -a")
  • Git基本工作流程$ git status# On branch master# Changed but not staged:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in workingdirectory)## modified: example.js#no changes added to commit (use "git add" and/or "git commit -a")
  • Git基本工作流程 A Basic Workflow Edit files Stage the changesReview your changesCommit the changes
  • Git基本工作流程git add
  • Git基本工作流程
  • Git基本工作流程
  • Git基本工作流程$git add example.js=======================$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: example.js#
  • Git基本工作流程$git add example.js==========================$ git status# On branch master# Changes THAT ARE STAGED:# (use "git reset HEAD <file>..." to unstage)## modified: example.js#
  • Git基本工作流程$vim example.js=================Console.log(“hello,longzang!”);=>(文件编辑)Console.log(“hello,fahai!”);
  • Git基本工作流程$vim menhu.js======================Console.log(“who is fumei!”);
  • Git基本工作流程$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: example.js## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: example.js## Untracked files:# (use "git add <file>..." to include in what will be committed)## menhu.js
  • Git基本工作流程$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)# Staged# modified: example.js## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: example.js## Untracked files:# (use "git add <file>..." to include in what will be committed)## menhu.js
  • Git基本工作流程$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: example.js## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: example.js# Unstaged# Untracked files:# (use "git add <file>..." to include in what will be committed)## menhu.js
  • Git基本工作流程$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: example.js## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: example.js## Untracked files:# (use "git add <file>..." to include in what will be committed)## menhu.js
  • Git基本工作流程You have to stage a file after you edit it文件编辑必暂存(add it!)
  • Git基本工作流程You have to stage a file after you edit it
  • Git基本工作流程 A Basic Workflow Edit files Stage the changesReview your changesCommit the changes
  • Git基本工作流程git commit
  • Git基本工作流程
  • Git基本工作流程
  • Git基本工作流程$ git commit example.js -m modify example.js‘
  • Git基本工作流程 A Basic WorkflowEdit files vim / phpstorm/ etc.Stage the changes git add (file)Review your changes git statusCommit the changes git commit
  • Git基本工作流程 A Basic WorkflowEdit files vim / phpstorm /etc.Commit the changes git commit -a
  • Git基本工作流程What’s going on here?
  • Git对象$ git commit menhu.js -m add menhu.js[master b6d7148] add menhu.js 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 menhu.js
  • Git对象 $gitk图形化工具git log
  • Git对象
  • Git对象B6d7148ecbb4930ea209a8c68f32ae7031ae861fFile + Header SHA-I SHA-1 校验和$ git cat-file -p b6d7148ecbb4930ea209a8c68f32ae7031ae861ftree 8d47beb17cd4f887dbcbdf110c5496853ae22416parent d8154ef6de0882959a975e20a57d8c4040d0eb7eauthor temu <temu.psc@taobao.com> 1331793217 +0800committer temu <temu.psc@taobao.com> 1331793217 +0800add menhu.js
  • Git对象
  • Git对象
  • Git对象
  • Git对象
  • Git对象
  • Git对象
  • Git对象
  • Git对象
  • 分支和合并Branching and Merging
  • Git分支Branches 分支
  • Git分支
  • Git分支git branch
  • Git分支git checkout
  • Git分支
  • Git分支
  • Git分支
  • Git分支
  • Git分支
  • Git分支
  • Git分支
  • Git分支
  • Git分支
  • Git分支
  • Git分支
  • Git分支
  • Git分支what is a branch, really? 分支到底是神马?
  • Git分支$ find .git/refs.git/refs.git/refs/heads.git/refs/heads/b2.git/refs/heads/master.git/refs/tags
  • Git分支$ find .git/refs.git/refs.git/refs/heads.git/refs/heads/b2.git/refs/heads/master.git/refs/tags
  • Git分支$ find .git/refs.git/refs.git/refs/heads.git/refs/heads/b2.git/refs/heads/master.git/refs/tags$ cat .git/refs/heads/masterB6d7148ecbb4930ea209a8c68f32ae7031ae861f$ cat .git/refs/heads/b27102df97a580b089080e325ac8e69fac3fe55b3c
  • Git分支$ cat .git/HEADref: refs/heads/b2
  • Git合并Merging 合并
  • Git合并git merge
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并Why is this cool?
  • Git合并non-linear development
  • Git合并• clone the code that is in production• create a branch for issue #53 (iss53)• work for 10 minutes• someone asks for a hotfix for issue #102• checkout ‘production’• create a branch (iss102)• fix the issue• checkout ‘production’, merge ‘iss102’• push ‘production’• checkout ‘iss53’ and keep working
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • Git合并
  • 好用的 GUI 省去记忆的烦恼乌龟GIT 概览 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 详情• Windows xp +• 基于 msysgit 1.6.1+• 官方地址: http://code.google.com/p/tortoisegit/ 159
  • Sharing gitGITHUB 介绍 160
  • Git远程Remotes 远程
  • Git远程远程分支(remote branch)是对 远程仓库中的分支的索引
  • Git远程git remote
  • 添加远程分支$git remote add pingan git@github.com:pingan1927/example.git$git remote$git remote –v$git remote show pingan$git branch -a
  • 更新远程分支 $git fetch pingan同步远程服务器上的数据到本地
  • 合并远程分支$ git merge (远程仓库名) (分支名)
  • Pull = fetch + merge
  • 推送本地分支$ git push (远程仓库名) (分支名) 推送本地分支
  • Thank You!