本帖最后由 shenzhenwan10 于 2016-5-19 18:19 编辑

最近启动的即时网络爬虫项目,采用开源的方式,相关代码会存放在github上。
本人所在的公司之前是使用另一个版本控制工具svn。
趁这个机会,学习了一下git的安装和使用,记录下来与大家分享。

一.  git的特点
之前使用的svn,每次保存的是“变化”,checkout的时候是获取"数据快照”。
git每次保存的是数据快照而不是变化,从远程仓库clone的时候,是把整个库都clone到本地,包含所有历史版本的数据。
所以git大部分操作是在本地,速度快,仓库在每个做了clone的用户/机器处都有一个完整拷贝。

二. git安装
1.  Windows上的安装
    下载地址:https://git-for-windows.github.io/

2.  Linux上从源代码安装
2.1 安装依赖包   
       centos系统:   $ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
       乌班图系统:    $ apt-get installlibcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev

2.2 下载git官方的最新版本源代码:
      下载地址: http://git-scm.com/download

2.3 编译并安装
    下面以版本1.7.2.2为例。
      $ tar -zxf git-1.7.2.2.tar.gz
      $ cd git-1.7.2.2
      $ make prefix=/usr/local all
      $ sudo make prefix=/usr/localinstall

3. Linux上安装编译好的二进制包
       centos系统:   $ yum install git-core
       乌班图系统:    $apt-get install git

三. git使用
1.  配置
    查看现有配置:  $ git config –list
    设置或修改:
       $ git config--global user.name "John Doe"
       $ git config--global user.email johndoe@example.com
2.  查看帮助
       $ git help xxxx
       $ git xxxx --help
       $ man git-xxxx
3.  使用本地仓库
       $ git init
       $ git clone git://github.com/schacon/simplegit-progit.git
       $ git log
       $ git status
       $ git commit –a –m “message:xxxx”
4.  使用远程仓库
      查看:   $ git remote –v      
      添加远程仓库到本地:$ git remote add prigit://github.com/gz51837844/pachong.git
      
      从远程仓库拿数据:
$ git fetch [remote-name]
      
      推送数据到远程仓库:
$ git push origin master      
      查看远程参考信息
: $ git remote show origin


以上所列是基本的使用,更多的详细内容请查阅手册。
参考: Pro Git book中文版
举报 使用道具
| 回复

共 1 个关于本帖的回复 最后回复于 2016-5-29 21:31

Fuller 管理员 发表于 2016-5-29 21:31:28 | 显示全部楼层
看到一篇文章,能在github上写博客,不知是真是假:http://www.jianshu.com/p/1260517bbedb
举报 使用道具
您需要登录后才可以回帖 登录 | 立即注册

精彩推荐

  • Gephi社会网络分析-马蜂窝游记文本分词并同
  • Gephi社会网络分析-基于马蜂窝游记文本以词
  • 知乎话题文本根据词语间距筛选后生成共词矩
  • 马蜂窝游记文本分词后以词语间距为筛选条件
  • 学习使用apriori算法挖掘关联关系

热门用户

GMT+8, 2024-3-29 01:04