美文网首页服务器方面Git
Laravel--入门篇(Git仓库的建立与Git服务器的搭建)

Laravel--入门篇(Git仓库的建立与Git服务器的搭建)

作者: Junting | 来源:发表于2016-09-24 13:08 被阅读1073次

安装git

twitch@ServerTwo:~$ clear
twitch@ServerTwo:~$ sudo su
root@ServerTwo:/home/twitch# apt-get install git
root@ServerTwo:/home/twitch# git --version
git version 2.7.4

进入站点目录,会发现隐藏文件 有个 .gitignore ,先创建的laravel项目,怎么会出现git相关文件呢,laravel本身就是使用Git项目版本管理工具来管理的,所以天生就带!

扩展知识点

.gitignore 文件 git忽略文件

/vendor                第三方库
/node_modules          加载模块    
/public/storage
Homestead.yaml
Homestead.json
.env                    环境变量配置
~     

搭建git服务器仓库

安装完git 还需要设置下仓库管理员身份信息

root@ServerTwo:/var/www/xdh# git config --global user.email "you@example.com"
root@ServerTwo:/var/www/xdh# git config --global user.name "Your Name"

start building git server

root@ServerTwo:/var/www/xdh# git init     //初始化一个版本仓库
root@ServerTwo:/var/www/xdh# git status   // 产看git当前状态
root@ServerTwo:/var/www/xdh# git add --all  //添加所有更改文件
root@ServerTwo:/var/www/xdh# git status     
root@ServerTwo:/var/www/xdh# git commit -m "初始化版本仓库"    //修改的文件把存储在暂存区的文件提交到仓库,添加更改的信息,必须要有,不然报错  -m 添加操作日志

root@ServerTwo:/var/www/xdh# git status
位于分支 master
无文件要提交,干净的工作区

创建添加git用户

root@ServerTwo:/var/www# adduesr git

克隆出一个裸仓库(就是只有站点项目里 的.git 文件夹,其他的都没有),便于分支提交到裸仓库,然后主分支来合并

root@ServerTwo:/var/www# git clone --bare xdh xdh.git
root@ServerTwo:/var/www# ls -l
总用量 20400
drwxrwxrwx  2 root   root       4096 9月  12 16:31 html
-rw-r--r--  1 root   root   20872294 8月  23 12:59 mediawiki-1.23.15.tar.gz
drwxrwxrwx 14    501 staff      4096 9月  13 10:00 wiki
drwxrwxr-x 12 twitch twitch     4096 9月  13 10:41 xdh
drwxr-xr-x  7 root   root       4096 9月  13 11:06 xdh.git

移动裸仓库到git用户家目录下

root@ServerTwo:/var/www# mv xdh.git /home/git/

移动了用户,但是用户和用户组还是root的!
需要修改用户组和用户

root@ServerTwo:/home/git# chown -R git:git xdh.git

修改好后,分支就可以通过git用户进行推送和拉取数据了!

本地 克隆仓库

C:\Users\Administrator\Desktop>git clone git@192.168.20.238:xdh.git
Cloning into 'xdh'...
The authenticity of host '192.168.20.238 (192.168.20.238)' can't be established.
ECDSA key fingerprint is SHA256:z53aySwFet+5j/F7lRh8Tg3ZBB/m8AR7/svaovsy6DQ.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.20.238' (ECDSA) to the list of known hosts.
git@192.168.20.238's password:
remote: 对象计数中: 103, 完成.
remote: 压缩对象中: 100% (84/84), 完成.
remote: Total 103 (delta 6), reused 0 (delta 0)
Receiving objects:  52% (54/103)
Receiving objects: 100% (103/103), 42.73 KiB | 0 bytes/s, done.
Resolving deltas: 100% (6/6), done.
Checking connectivity... done.

C:\Users\Administrator\Desktop>

这样就成功克隆下仓库了!但是需要输入密码!

不需要输入密码,就要通过密钥 -- 公钥和私钥!

生成 公钥和私钥
root@ServerTwo:/home/git# ssh-keygen -t rsa
root@ServerTwo:/home/git# ls
examples.desktop  twitch  twitch.pub  xdh.git

创建好,密钥好后,重定向!添加密钥

root@ServerTwo:/home/git# ls
examples.desktop  twitch  twitch.pub  xdh.git
root@ServerTwo:/home/git# mkdir .ssh

root@ServerTwo:/home/git# cat twitch.pub >> .ssh/authorized_keys
root@ServerTwo:/home/git# cat .ssh/authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCcrdNuVD09JxYzmCJiAu2ldLclRPqUaFQs3WzDihbxoPjM3DH1W1NnN/uckzzJiSpLg40IojOYjnnSXQKqJmbji0+d1fo0b3knGR+2vFkLWIUsMHJPguA4m6FETBWFGDFx9bXwi30BeDeKJzfp7zh4SlCntqLkUV/KaMcZhx4Q+qyXP3/D/WbFrW1bTgowEMGX9IMRUElxQFCZF7nJGPMO72c8cVLeXn8YYLhAimN74qo0stUxHzsYjSSJ6NkRPyr0gv5ipBvupR7ddOJsWi9aUaOXJ5EjjFyPdtM6WlMz/nsO/x2fQWXqK03ori/CvtlydDNDt9Kcct9SMRuxRfiL root@ServerTwo

相关文章

  • Laravel--入门篇(Git仓库的建立与Git服务器的搭建)

    安装git 进入站点目录,会发现隐藏文件 有个 .gitignore ,先创建的laravel项目,怎么会出现gi...

  • git

    git 如果服务器上没有本地代码git仓库,先在服务器建立1个git仓库,然后在本地git仓库增加服务器仓库URL...

  • git服务器搭建

    最近要用自己的linux搭建一个git仓库存放代码,所以折腾了一下git服务器: git下载 账号建立 切换roo...

  • Git 服务器搭建

    搭建一台Git服务器作为私有仓库使用。 以 Centos 为例搭建 Git 服务器。 1、安装Git 创建一个gi...

  • Git 命令总结

    Git 命令总结 基本命令 远程仓库 分支管理 标签管理 自定义 Git 搭建 Git 服务器 安装 git:$ ...

  • 在自己服务器搭建git仓库

    在网上有很多教程如何搭建。记录一下搭建git仓库的一些理解Git 服务器搭建我们远程仓库使用了 Github,Gi...

  • SpringBoot实战-Guns项目(发布到docker)

    前言 用自己搭建的git服务器创建一个guns.git仓库,把代码上传到git服务器中, 在服务器root用户,把...

  • auto601专属git仓库 ftp服务器

    现已搭建601专属远程git仓库和ftp服务器 1. git仓库 仓库使用ssh登录 使用前请先设置name&em...

  • Git使用学习(二)

    一、共享版版本库建立: 1.搭建git服务器真实的git服务器的搭建需要使用Linux来进行搭建,搭建难度大且繁琐...

  • 模块化之私有服务器管理基础框架

    0.搭建git本地私有服务器 Git服务器搭建全过程分步详解 1.链接git仓库 2.在本地链接一个文件夹 将项目...

网友评论

    本文标题:Laravel--入门篇(Git仓库的建立与Git服务器的搭建)

    本文链接:https://www.haomeiwen.com/subject/ouexyttx.html