一、Git的特性

Speed 速度(git是用c语言写的。一般都是提交到本地)

Simple design

Strong support for non-linear development (thousands of parallel branches)(强有力的支持非线性开发) 

Fully distributed(分布式)

Able to handle large projects like the Linux kernel efficiently (speed and data size)

二、Git的架构原理

1.快照和索引而不是增量,svn是增量

2.差点儿全部的操作都是本地的

3.Git文件的三个状态

Committed :文件安全的存储在你的本地. 

Modified :你改动了文件,但还未提交到你的仓库. 

Staged : 已经标记了一个已改动文件到下一个版本号的快照





对应流程例如以下:

(1),工作区改动文件

(2),adding 快照到stage区域

(3),commit 提交到仓库

4.文件状态生命周期

三、安装Git及使用前的准备

1.安装,直接上官网下载安装

2.安装完毕之后查看系统环境变量,设置身份

(1),了解系统环境变量

/etc/gitconfig

.gitconfig 





(2),设置身份

$ git config --global user.name "John Doe"

$ git config --global user.email johndoe@example.com





(3),设置编辑器(可选)

$ git config --global core.editor emacs





(4),设置你的比較工具(可选)

$ git config --global merge.tool vimdiff





(5),检查你的配置(可选)

$ git config --list





(6),帮助

$ git help <verb>

$ git <verb> --help

3.开发前需理解的四个区域

blessed (remote) repository 远程仓库

local repository 本地仓库

stage area 暂时区

work area 工作区

四、Git相关命令

基本命令

1.初始化

(1)init 进入工作区间目录,git init

(2)clone 从远程server调用git clone git://github.com/wsj/test.git

2.由工作区workspace添�到暂时区staged,add命令

git add *.java

git add wsj.txt

3.由暂时区staged提交到本地仓库local repository

git commit  -m "log"

4.查看提交状态

git status

5.忽略文件或目录

新建.gitignore文件,写入要忽略的文件名称就可以

6.查看三个区域文件的差别

$git diff --staged : workspace VS staged  .

$git diff --cached :staged  VS local repo

7.回滚 reset

git reset 三种模式

git reset --mixed 保留工作区源代码,暂时区和本地仓库回滚

git reset --soft  保留工作区和暂时区源代码,本地仓库回滚

git reset --hard 工作区,暂时区,本地仓库都回滚





git reset --hard HEAD^ 回滚全部内容到上一个版本号,后边可加上文件名称

git reset --hard HEAD~3回滚到上3个版本号

git reset --hard  origin/master 回滚到和远程仓库一致

8.删除移动 rm mv

删除但未提交到本地仓库,这时假设想找回文件,使用git checkout filename

共享及更新项目

1.从远程仓库中更新 fetch pull

git fetch origin 相当于是从远程获取最新版本号到本地,不会自己主动merge

git pull origin 相当于是从远程获取最新版本号并merge到本地

具体介绍,请看一下博客

http://blog.csdn.net/hudashi/article/details/7664457

2.提交到远程仓库

git push origin master

3.远程仓库 remote

列出远程仓库

git remote

git remote -v 显示远程地址





//加入�远程仓库

git remote add pb git://github.com/sundyhome/ticgit.git

git remote rename pb paul

git remote rm paul

git remote show origin

观察比較 log diff

查找tag相应的commit id

 git log --oneline --decorate

分支管理及合并

1.分支branch

git branch branchname创建分支



查看

git branch 列出分支

git show-branch 列出分支,并列出差异

git diff branch1 branch2

git whatchanged

2.切换分支checkout

3.分支合并merge

git merge "merge branch1 to master" HEAD branch1

还有一种做法

git checkout master

git pull . branch1

4.版本号tag

git tag -a ver1.0 -m "my version 1.0"





//show ver1.0 命令查看对应标签的版本号信息,并连同显示打标签时的提交对象。

git show ver1.0





//switch ver1.0

git checkout ver1.0





怎样恢复到tag1.0,看以下文章

http://blog.csdn.net/csfreebird/article/details/8022051

Git使用总结-so easy的更多相关文章

  1. Git工作流指南:Gitflow工作流 Comparing Workflows

    Comparing Workflows The array of possible workflows can make it hard to know where to begin when imp ...

  2. git workflows

    https://www.atlassian.com/git/tutorials/comparing-workflows Comparing Workflows The array of possibl ...

  3. How to get started with GIT and work with GIT Remote Repo

    https://www.ntu.edu.sg/home/ehchua/programming/howto/Git_HowTo.html#zz-7. 1.  Introduction GIT is a ...

  4. Git学习0基础篇(下)

    server上的 Git - 协议 Git能够使用四种基本的协议传输资料:本地协议(Local).HTTP 协议.SSH(Secure Shell) 协议以及 Git 协议.眼下使用最普及的是 SSH ...

  5. Git实战(三)环境搭建

    上次的博文中.我们介绍了一下关于Git作为版本号控制工具的基本原理,接下来我们来搭建一个主要的Git环境(因为我使用的是Windows系统.所以重点側重在这方面). Git安装 Git的安装很easy ...

  6. Git学习记录(一)

    本篇文章介绍Git的本地使用 Git是什么? Git是世界上最先进的分布式版本控制系统. 那么什么是版本控制系统? 我们来举个例子,假设我创建了一个项目Project.1,里面写了一个README.t ...

  7. Latex Notes

    latex Table of Contents 1. Presentation/Slides with Beamer 2. Drawing in LaTex With TikZ 3. Tracked ...

  8. release git tag easy use

    #!/usr/local/env bash FLOW_VERSION=v2.0-rc-`date +"%Y-%m-%dT%H-%M-%S"` echo "version: ...

  9. GIT命令总结,so easy

    一:GIT命令实战(码云) https://oschina.gitee.io/learn-git-branching/ 提交 git commit 创建分支 git branch <name&g ...

随机推荐

  1. niu人

    金步国简历 金步国简历 基本资料 姓名 金步国 性别 男 年龄 30 籍贯 江苏 淮安 院校 同济大学 专业 土木工程 学历 本科肄业 工作经验 5年 期望地点 长江以南 期望薪水 18000/月 个 ...

  2. ZOJ 3529 A Game Between Alice and Bob(博弈论-sg函数)

    ZOJ 3529 - A Game Between Alice and Bob Time Limit:5000MS     Memory Limit:262144KB     64bit IO For ...

  3. ACM-计算几何之Quoit Design——hdu1007 zoj2107

    Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  4. XMPP协议简介

    XMPP(息处理现场协议)是基于可扩展标记语言(XML)的协议.它用于即时消息(IM)以及在线现场探測.XMPP协议採用的是client-server架构,全部从一个client发到还有一个clien ...

  5. 三框架:使用数据源dbcp注意

    使用spring整合hibernate时间,需要使用该数据源,数据源使用apache的dbcp,使用dbcp当需要依靠pool的jar包.选择dbcp和pool当你需要注意. DBCP 2 compi ...

  6. 在C#或者SWT上跨进程访问SWT控件的问题

    可能为了进程安全,无论是C#的Form还是Eclipse的SWT,都不允许跨进程访问控件. 通俗一点说就是: A进程创建了控件Widget,若想在B进程中访问控件Widget就会报错,必须在创建Wid ...

  7. 阿里云免费试用之体验——阿里云serverECS试用心得

    自上次參加了阿里云的开发人员大会回来 心里就一直惦记着阿里云 由于曾经各种各样什么的server也用了不少 年前開始接触阿里云 一直没有给予很多其它的关注 參加了这次的开发人员大会后 就想更进一步的了 ...

  8. selenium通过WebDriverWait实现ajax测试

    selenium通过WebDriverWait实现ajax测试 AndroidDriver driver = new AndroidDriver(); driver.get("http:// ...

  9. httl开源JAVA模板引擎,动态HTML页面输出

    HTTL(Hyper-Text Template Language)是一个适用于HTML输出的开源JAVA模板引擎,适用于动态HTML页面输出,可用于替代JSP页面,它的指令类似于Velocity. ...

  10. hdu4578(线段树)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4578 题意:n个数,初始值为0,4种操作: 1.将某个区间所有值加上另一个值: 2.将区间所有值都乘上 ...