zoukankan      html  css  js  c++  java
  • ubuntu 安装git

    1 git服务器搭建

    1.1 安装git

    zzx@zzx:~$ sudo apt-get install git

    1.2 创建 git账户

    zzx@zzx:~$ sudo adduser git

    正在添加用户"git"...

    正在添加新组"git" (1002)...

    正在添加新用户"git" (1001)到组"git"...

    创建主目录"/home/git"...

    正在从"/etc/skel"复制文件...

    输入新的 UNIX密码:

    重新输入新的 UNIX密码:

    passwd:已成功更新密码

    正在改变 git的用户信息

    请输入新值,或直接敲回车键以使用默认值

        全名 []:

        房间号码 []:

        工作电话 []:

        家庭电话 []:

        其它 []:

    这些信息是否正确? [Y/n] y

    注意:记住git账户密码

     

    1.3 创建仓库

    我是在/home下创建的myreponsitory文件夹,在此文件夹下初始化一个空的MyProject.git文件夹改MyProject.git的所有权改MyProject.git的所有权

     

    zzx@zzx:~$ cd /home

    zzx@zzx:/home$ ls

    git  zzx

    zzx@zzx:/home$ sudo mkdir myreponsitory

    zzx@zzx:/home$ ls

    git myponsitory  zzx

    zzx@zzx:/home$ cd myreponsitory/

    zzx@zzx:/home/myreponsitory$ sudo git init --bare MyProject.git

    查看一下文件结构:

     

    zzx@zzx:/home$ tree -d (需要安装tree)

    .

    ├── git

    ├──myreponsitory

    │  └── MyProject.git

    │      ├── branches

    │      ├── hooks

    │      ├── info

    │      ├── objects

    │      │   ├── info

    │      │   └── pack

    │      └── refs

    │          ├── heads

    │          └── tags

    └── zzx

     

    1.4 更改MyProject.git的权限

     

    zzx@zzx:/home/myreponsitory$ ls -la

    总用量 12

    drwxr-xr-x 3 root root 4096 3月  19 14:52 .

    drwxr-xr-x 5 root root 4096 3月  19 14:51 ..

    drwxr-xr-x 7 root root 4096 3月  19 14:52MyProject.git

     

    zzx@zzx:/home/myreponsitory$ sudo chown -R git:gitMyProject.git

    zzx@zzx:/home/myreponsitory$ ls -la

    总用量 12

    drwxr-xr-x 3 root root 4096 3月  19 14:52 .

    drwxr-xr-x 5 root root 4096 3月  19 14:51 ..

    drwxr-xr-x 7 git git  4096 3月  19 14:52MyProject.git

     

    1.5 获取服务器的ip

    zzx@zzx:$ ifconfig -a

     

    ---192.168.1.106 

    至此,在同一局域网中搭建好git服务器。

    2 客户端测试

    2.1 windows测试1

    在windows下安装好git,请自行搜索安装教程。

    2.1.1 从服务器克隆仓库

     

    Administrator@ZZX MINGW64~ (master)

    $git clone git@192.168.1.106:/home/myreponsitory/MyProject.git

    Cloninginto 'MyProject'...

    git@192.168.1.106'spassword:

    warning:You appear to have cloned an empty repository.

    Checkingconnectivity... done.

     

    2.2.2 往仓库推送内容

    在MyProject文件夹中新建一个test.txt文件,随便写点内容。

     

    Administrator@ZZX MINGW64~/MyProject (master)

    $git add test.txt

     

    Administrator@ZZX MINGW64~/MyProject (master)

    $git commit -m "tets"

    [master(root-commit) 6a3171f] tets

     1 file changed, 1 insertion(+)

     create mode 100644 test.txt

     

    Administrator@ZZX MINGW64~/MyProject (master)

    $git push origin master

    git@192.168.1.106'spassword:

    Countingobjects: 3, done.

    Writingobjects: 100% (3/3), 209 bytes | 0 bytes/s, done.

    Total3 (delta 0), reused 0 (delta 0)

    Togit@192.168.1.106:/home/myreponsitory/MyProject.git

     * [new branch]      master -> master

     

    在windows上测试成功!

     

    2.2 在虚拟机(ubuntu)上测试2

     

    2.2.1 安装好git

    同第一步

    2.2.2 输入用户名和邮箱(随便填)

    git config –global user.name “aaa”

    git config –global user.email “aaa@163.com”

    2.2.3 测试clone和push

    完全同windows操作,clone下来的仓库中有刚才windows上推送上去的test.txt文件,可以自己再创建一个文件push到服务器进行测试。

  • 相关阅读:
    debian 降级
    linux 常用查看设备命令
    viewstate
    linux图形界面编程基本知识
    Java 不适合编写桌面应用
    temp
    ASP.NET中26个常用性能优化方法
    三层架构与MVC的关系
    分页查询前台HTML+后台asp.net代码
    windows身份验证登入数据库 iis 无法访问数据库
  • 原文地址:https://www.cnblogs.com/aaron-agu/p/8857403.html
Copyright © 2011-2022 走看看