zoukankan      html  css  js  c++  java
  • git 安装笔记

    看到不少公司将版本控制工具迁移到了git,准备做下尝试。

    先找一台服务器安装git ,服务器环境:

    [gita@namenode .ssh]$cat /proc/version
    Linux version 2.6.9-42.ELsmp (bhcompile@hs20-bc1-1.build.redhat.com) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-2)) #1 SMP Wed Jul 12 23:27:17 EDT 2006

    官方文档地址:http://git-scm.com/book/zh/  写的很详细,官方推荐用包管理方式安装,不过按惯例,在公司我选择编译安装# cd /home/download/

    # wget https://git-core.googlecode.com/files/git-1.8.3.tar.gz
    # tar -xzvf git-1.8.3.tar.gz
    # cd git-1.8.3
    # make prefix=/usr/local all
    # make prefix=/usr/local install

    这里必须要加上 prefix=/usr/local  因为在后面从客户机向服务端传送、下载文件时,默认命令路径是这里。

    此时输入git 出现如下结果

    # git
    usage: git [--version] [--help] [-c name=value]
               [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
               [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
               [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
               <command> [<args>]
    ...

    接下来创建一个git私有账号,专门用来管理git

    # useradd git -g users -d /home/git/

     将 /home/git/ 设置成git账号的家目录。

    这里使用ssh方式登录,账户没有密码,而是使用ssh key的方式,key有passphrase。

    # su - git
    $ ssh-keygen -t rsa -f ~/.ssh/git_key 
    Generating public/private rsa key pair.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/git/.ssh/git_key.
    Your public key has been saved in /home/git/.ssh/git_key.pub.
    The key fingerprint is:
    ************************************************ git@namenode

     在家目录下 ~/ .ssh/ 目录下找到git_key.pub

    $ cd ~/.ssh/
    $ touch authorized_keys
    $ cat git_key.pub authorized_keys

    将服务器上的git_key 和 git_key.pub 传送回客户机。客户机上我使用的client工具是 secureCrt 。使用git用户和git_key 成功登录服务器,git私有账号设置成功。

    接下来开始使用git客户端工具,测试推数据(push)和拉数据(pull)。我选择的客户端工具是小乌龟 TortoiseGit ,用过svn的人应该对它不陌生,svn有个对应的客户端工具 TortoiseSVN。

    下载下来安装好,发现小乌龟用的是putty类型的key。到小乌龟的安装目录下 C:\Program Files\TortoiseGit\bin ,有个 puttygen.exe 。操作如下图:

    选中 git_key 后输入passphrase 保存为 putty格式key, 即 git_key 和 git_key.ppk 。

    进入服务器端,在家目录下新建一个测试仓库,git里叫仓库。

    $ mkdir test
    $ cd test
    $ git --bare init

    创建了一个空的仓库 test 。在客户机上使用小乌龟clone仓库。右键 Git Clone ,添加服务器信息,如下图。选中前面生成的key。复制成功。上传文件类似,提交后点 push 成功。

    至此,git 算是正式安装完毕。

    由于开发工具是eclipse,查到git的eclipse插件,egit ,我的eclipse版本是indingo . 在它的help -> eclipse marketplace 里有。

    设置eclipse的ssh key,打开 windows -> preference -> General -> Network Connection -> SSH2 ,选择 Key Management 点 Load Existing Key ,选中 git_key 输入passphrase,点保存,然后点 Apply

    至此,egit配置完毕,可以在eclipse上使用。

  • 相关阅读:
    给router-link 标签添加事件@click 、@mouseover等无效
    elementUI的导航栏在刷新页面的时候选中状态消失的解决
    查看mysql数据库中的所有用户
    已经安装了客户端,但是cmd输入sqlcmd报错:Sqlcmd:Error:Connection failure.SQL Native Client is not installed correctly
    在运行bat文件时,报错发生系统错误123,文件名,目录名或卷标语法不正确
    数据库表空间文件被删除后,再删除表空间时报错
    oracle在exp导出时报错PLS-00201: identifier 'EXFSYS.DBMS_EXPFIL_DEPASEXP' must be declared
    oracle compile 编译无效对象
    Oracle 导出错误 EXP-00000~EXP-00107
    修改oralce数据库用户名和密码
  • 原文地址:https://www.cnblogs.com/seanvon/p/git.html
Copyright © 2011-2022 走看看