Linux端创建Git服务器,Windows端做客户端

本文详细介绍如何在Ubuntu上安装Git,并创建Git服务器端。包括创建git用户、配置仓库、从Windows克隆Linux仓库以及配置gitlog等步骤。

Ubuntu上安装Git

  • sudo apt-get install git ,之后哎终端测试git --version是否有信息输出;

服务器端创建 git 用户

  1. 切换到用户目录 :cd 即可,我的当前目录是/home/tom;在这里插入图片描述
  2. 查看用户是否存在 :id tom;在这里插入图片描述不存在就创建用户和密码(一般省略) :useradd tom,passwd git ;
  3. 用户目录下创建文件夹:cd ~;mkdir GitResponsity;
  4. 创建测试空目录 :mkdir -p home/tom/GitResponsity/testResponsity.git;
  5. 进入测试目录并初始化(很重要) :git init --bare ./testResponsity.git;
  6. 修改仓库owner : git init --bare home/tom/GitResponsity/testResponsity.git;
  7. 查看.git文件夹的所有者:ll,如果部位tom用户就将用户修改为tom,chown -R tom:tom testResponsity.git/;

windows克隆Linux仓库

  1. 本地创建文件夹:假设GitResponsity;
  2. 克隆远程仓库:切换到上面创建的文件夹下;git clone tom@ubuntu的IP第地址:/home/tom/GitResponsity/testResponsity.git
  3. 创建测试文件:创建一个a.txt文件;
  4. 添加提交并推送到远程仓库:切换到GitResponsity下,git add a.txt,
    git commit -m “test commit”, git push tom@ubuntu的IP第地址:/home/tom/GitResponsity/testResponsity.git;

配置git log

windows客户端需要在 .gitconfig文件中配置相应的输出格式;
在这里插入图片描述

lg1 = log --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' -10 --all
lg3 = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --

.gitconfig路径:C:\Users\Administrator
使用方式:
在这里插入图片描述

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值