当前位置:首页 » 云服务器 » linux搭建git服务器

linux搭建git服务器

发布时间: 2022-02-17 12:42:07

linux搭建git服务器后怎么使用

linux搭建git服务器后怎么使用GitHub就是一个免费托管开源代码的远程仓库。但是对于某些视源代码如生命的商业公司来说,既不想公开源代码,又舍不得给GitHub交保护费,那就只能自己搭建一台Git服务器作为私有仓库使用。linux搭建git服务器后怎么使用

② linux搭建的gitlab服务器会在重启之后消失吗

linux搭建的gitlab服务器会在重启之后消失
1、由于在Windows Vista之后的版本默认并没有提供Telnet功能。如果需要使用Telnet就必须打开此项功能。以Windows 7为例,首先打开控制面板。

2、然后在控制面板中打开“程序和功能”。

3、再在左上角点击“打开或关闭Windows功能”。

4、在“打开或关闭Windows功能”对话框中勾选“Telnet客户端”,点击确定,系统会自动安装。到此Windows终端的工作已经完成。
5、Linux服务器开启Telnet服务
许多Linux系统在默认情况下是不安装Telnet服务的,如果需要使用就必须安装此项服务。安装的方法有很多,小编在这里只介绍yum安装Telnet服务,它的优点是能够自动检查安装包的依赖文件不用人为干预,当然前提是系统必须联网。在提示符下输入“yum install -y telnet-server”命令安装Telnet服务。最后出现Complete,代表安装完成。

③ linux如何搭建git

1、环境准备
服务器:CentOS 7.3 + git (1.8.3.1)
客户端:win10 + git (2.17.0.windows.1)
2、服务器安装git
yum install -y git
3、创建git用户,管理 git服务
[root@localhost home]# useradd git
[root@localhost home]# passwd git
4、服务器创建git 仓库
设置/home/git/repository-git 为git 服务器仓库,然后把 git 仓库的 owner 修改为 git 用户。
复制代码
[root@localhost git]# mkdir repository-git
[root@localhost git]# git init --bare repository-git/
Initialized empty Git repository in /home/git/repository-gt/
[root@localhost git]# chown -R git:git repository-git/
5、客户端安装git
下载 Git for Windows,地址:https://git-for-windows.github.io/
安装完之后,可以使用 Git Bash 作为命令行客户端。
5.1、选择一个目录 F:\project\sell 作为本地仓库,右键进入Git Bash 命令行模式
初始化本地仓库:git init
5.2、尝试克隆一个服务器的空仓库到本地仓库
git clone [email protected]:/home/git/repository-gt
第一次连接到目标 Git 服务器时会得到一个提示:
The authenticity of host '192.168.116.129(192.168.116.129)' can't be established.
RSA key fingerprint is SHA256:Ve6WV/.
Are you sure you want to continue connecting (yes/no)?
选择 yes:
Warning: Permanently added '192.168.116.129' (RSA) to the list of known hosts.
此时 C:\Users\用户名\.ssh 下会多出一个文件 known_hosts,以后在这台电脑上再次连接目标 Git 服务器时不会再提示上面的语句。

④ 如何用linux搭建git服务器,如果使用git

这个简单,你可以看看廖雪峰的git教程,http://www.liaoxuefeng.com/wiki/我就是在上面学的。花了2天时间,基本上掌握了。
如果你学Linux可以看看刘遄老师的博客www.linuxprobe.com上面还是很多干货。

⑤ 如何 连接 linux git服务器

1、前期准备 服务器上配置好的git git客户端 1.1 在服务器上安装git (本机所使用的linux是ubuntu) 在服务器输入命令:sudo apt-get install git即可 然后创建名字为git的用户组和用户 1.2 下载客户端 在浏览器地址栏输入:https://git-for-windows.github.io/ 回车后 点击Download进行下载 2、具体操作 2.1 在合适的位置创建一个目录充当git远程仓库(本机位置为/usr/testgit),然后使用init命令初始化仓库 在命令终端输入: sudo git init –bare 2.2 将git init生成的目录所属者改为git 输入命令:sudo chown -R git:git * 至此服务器端的操作完成。 在客户端合适位置使用git 客户端从服务器资源 2.3 首先打开git客户端 点击Git Bash Here 后出现 在git客户端命名终端输入: git clone git@xxxxxx:/rrrrr 其中xxxxxx是远程服务器的地址 rrrrr为git仓库所在位置 如果配置正确你选中的目录下会出现名字为testgit的文件夹 testgit文件夹下随意创建若干个文件 2.3 在git客户端上使用命令 git add 111.txt 222.txt 333.txt 或者使用git add .(将本文件夹下所有文件都add) 该命令的作用是告诉git把文件添加到git仓库 2.4 然后使用git commit命令将文件提交到git仓库 -m 后面的内容为本次提交文件的一些注释内容 此时文件还没有从本地仓库上传到远程服务器仓库 2.5 使用push命令将本地仓库中的内容提交到远程仓库 在git客户端命令终端输入:git push origin master 至此本地仓库中的文件上传已经上传到远程服务器仓库。 在其他文件夹下再次使用 git clone 命令 从远程服务器同步仓库

⑥ linux怎么搭建git服务器

GitHub就是一个免费托管开源代码的远程仓库。但是对于某些视源代码如生命的商业公司来说,既不想公开源代码,又舍不得给GitHub交保护费,那就只能自己搭建一台Git服务器作为私有仓库使用。
搭建Git服务器需要准备一台运行Linux的机器,强烈推荐用Ubuntu或Debian,这样,通过几条简单的apt命令就可以完成安装。
假设你已经有sudo权限的用户账号,下面,正式开始安装。
第一步,安装git:
$ sudo apt-get install git

第二步,创建一个git用户,用来运行git服务:
$ sudo adser git

第三步,创建证书登录:
收集所有需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所有公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个。
第四步,初始化Git仓库:
先选定一个目录作为Git仓库,假定是/srv/sample.git,在/srv目录下输入命令:
$ sudo git init --bare sample.git

Git就会创建一个裸仓库,裸仓库没有工作区,因为服务器上的Git仓库纯粹是为了共享,所以不让用户直接登录到服务器上去改工作区,并且服务器上的Git仓库通常都以.git结尾。然后,把owner改为git:
$ sudo chown -R git:git sample.git

第五步,禁用shell登录:
出于安全考虑,第二步创建的git用户不允许登录shell,这可以通过编辑/etc/passwd文件完成。找到类似下面的一行:
git:x:1001:1001:,,,:/home/git:/bin/bash

改为:
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell

这样,git用户可以正常通过ssh使用git,但无法登录shell,因为我们为git用户指定的git-shell每次一登录就自动退出。
第六步,克隆远程仓库:
现在,可以通过git clone命令克隆远程仓库了,在各自的电脑上运行:
$ git clone git@server:/srv/sample.git
Cloning into 'sample'...
warning: You appear to have cloned an empty repository.

剩下的推送就简单了。

⑦ 如何搭建linux git服务器与客户端

1.创建Gitblit安装目录 首先我们将在我们的服务器上建立一个目录,并在该目录下安装最新的Gitblit。 $ sudo mkdir -p /opt/gitblit $ cd /opt/gitblit 创建gitblit目录 2. 并解压 现在,我们将从Gitblit官方站点最新版的Gitblit。

⑧ 如何搭建linux git服务器

首先我们分别在Git服务器和客户机中安装Git服务程序(刚刚实验安装过就不用安装了):
[root@linuxprobe ~]# yum install git
Loaded plugins: langpacks, proct-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package git-1.8.3.1-4.el7.x86_64 already installed and latest version
Nothing to do

然后创建Git版本仓库,一般规范的方式要以.git为后缀:
[root@linuxprobe ~]# mkdir linuxprobe.git

修改Git版本仓库的所有者与所有组:
[root@linuxprobe ~]# chown -Rf git:git linuxprobe.git/

初始化Git版本仓库:
[root@linuxprobe ~]# cd linuxprobe.git/
[root@linuxprobe linuxprobe.git]# git --bare init
Initialized empty Git repository in /root/linuxprobe.git/

其实此时你的Git服务器就已经部署好了,但用户还不能向你推送数据,也不能克隆你的Git版本仓库,因为我们要在服务器上开放至少一种支持Git的协议,比如HTTP/HTTPS/SSH等,现在用的最多的就是HTTPS和SSH,我们切换至Git客户机来生成SSH密钥:
[root@linuxprobe ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
65:4a:53:0d:4f:ee:49:4f:94:24:82:16:7a:dd:1f:28 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
| .o+oo.o. |
| .oo *.+. |
| ..+ E * o |
| o = + = . |
| S o o |
| |
| |
| |
| |
+-----------------+

将客户机的公钥传递给Git服务器:
[root@linuxprobe ~]# ssh--id 192.168.10.10
[email protected]'s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.10.10'"
and check to make sure that only the key(s) you wanted were added.

此时就已经可以从Git服务器中克隆版本仓库了(此时目录内没有文件是正常的):
[root@linuxprobe ~]# git clone [email protected]:/root/linuxprobe.git
Cloning into 'linuxprobe'...
warning: You appear to have cloned an empty repository.
[root@linuxprobe ~]# cd linuxprobe
[root@linuxprobe linuxprobe]#

初始化下Git工作环境:
[root@linuxprobe ~]# git config --global user.name "Liu Chuan"
[root@linuxprobe ~]# git config --global user.email "[email protected]"
[root@linuxprobe ~]# git config --global core.editor vim

向Git版本仓库中提交一个新文件:
[root@linuxprobe linuxprobe]# echo "I successfully cloned the Git repository" > readme.txt
[root@linuxprobe linuxprobe]# git add readme.txt
[root@linuxprobe linuxprobe]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached ..." to unstage)
#
# new file: readme.txt
#
[root@linuxprobe linuxprobe]# git commit -m "Clone the Git repository"
[master (root-commit) c3961c9] Clone the Git repository
Committer: root
1 file changed, 1 insertion(+)
create mode 100644 readme.txt
[root@linuxprobe linuxprobe]# git status
# On branch master
nothing to commit, working directory clean

但是这次的操作还是只将文件提交到了本地的Git版本仓库,并没有推送到远程Git服务器,所以我们来定义下远程的Git服务器吧:
[root@linuxprobe linuxprobe]# git remote add server [email protected]:/root/linuxprobe.git

将文件提交到远程Git服务器吧:
[root@linuxprobe linuxprobe]# git push -u server master
Counting objects: 3, done.
Writing objects: 100% (3/3), 261 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/root/linuxprobe.git
* [new branch] master -> master
Branch master set up to track remote branch master from server.

为了验证真的是推送到了远程的Git服务,你可以换个目录再克隆一份版本仓库(虽然在工作中毫无意义):
[root@linuxprobe linuxprobe]# cd ../Desktop
[root@linuxprobe Desktop]# git clone [email protected]:/root/linuxprobe.git
Cloning into 'linuxprobe'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
[root@linuxprobe Desktop]# cd linuxprobe/
[root@linuxprobe linuxprobe]# cat readme.txt
I successfully cloned the Git repository

这篇是详细介绍Git的,中间有一部分是怎么去搭建,你可以看下

⑨ 怎样在linux 上搭建git +apache服务器

1:服务器端创建用户(git)
# sudo adsergit
2:客户端生成公钥,并
创建公钥:ssh-keygen,
在客户端的用户目录下查看生成的公钥和私钥对
#cd ~/.ssh
#ls
id_dsa id_dsa.pub

公钥所在的目录:windows在”C:/User/username/.ssh”目录下,linux在”~/.ssh”,~代表用户目录
3:服务器git用户下添加各个用户公钥,并配置ssh服务
将各个用户的公钥文件追加在服务器git用户的authorized_keys文件中
$ cat id_rsa.john.pub >> ~/.ssh/authorized_keys
$ cat id_rsa.josie.pub >> ~/.ssh/authorized_keys
$ cat id_rsa.jessica.pub >> ~/.ssh/authorized_keys
修改.ssh和authorized_keys的权限).忘记下面的话,会每次输入密码,(ps,被这个坑了好久)
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

4,在git用户下创建git库
cd gitDIR
mkdir project.git
cd project.git
git init –bare
5,客户端使用
提交自己的库
mkdir project
cd project
git init
vi first.txt
git remote add origin gitserver/gitDIR/project.git
git push origin master
克隆:git clonegit@gitserver/gitDIR/project.git
6,限制开发者登陆
默认情况下,能够连接git服务器用户也可以通过ssh直接登陆服务器,那么服务器将会存在被多用户登入的风险,限制的方法是:
Vi /etc/passwd

git:x:1000:1000::/home/git:/bin/sh

该行修改后的样子如下:
git:x:1000:1000::/home/git:/bin/git-shell

⑩ 如何在linux下上传到git服务器

GitHub就是一个免费托管开源代码的远程仓库。但是对于某些视源代码如生命的商业公司来说,既不想公开源代码,又舍不得给GitHub交保护费,那就只能自己搭建一台Git服务器作为私有仓库使用。

热点内容
最好的加密移动硬盘 发布:2024-09-22 12:35:58 浏览:155
c语言编程贪吃蛇 发布:2024-09-22 12:34:21 浏览:744
青椒云电脑什么配置 发布:2024-09-22 12:24:50 浏览:277
pythongbkunicode 发布:2024-09-22 12:24:06 浏览:991
空调压缩机保险在哪里 发布:2024-09-22 12:18:01 浏览:363
笔记本配置看哪些 发布:2024-09-22 12:06:41 浏览:856
魔兽地图脚本制作 发布:2024-09-22 12:04:48 浏览:799
算法衰减 发布:2024-09-22 11:58:42 浏览:49
抖音安卓机客服中心在哪里 发布:2024-09-22 11:58:40 浏览:357
php监控系统 发布:2024-09-22 11:49:58 浏览:930