导航:首页 > IDC知识 > git服务器Linux

git服务器Linux

发布时间:2020-12-24 16:35:51

1、如何在linux删除git服务器

直接卸载掉git就行了:

apt-get uninstall git-core

2、如何在Linux环境下建立Git Server并设置用户

我的演示环境是一个Amazon EC2的instance,安装好了Ubuntu 16.04,并且已经安装有git。

我们想达到的目的是这样的专:

建立一个名属为/srv/git的文件夹,对于我们当前项目,会有一个相应的my_project.git文件夹,我们可以在本地使用git push origin master或者git pull origin master命令来推送或者取回相应的文件。

首先git是存在多种protocol的,我们使用的是ssh。所以在建立用户的时候,我们需要建立相应的public key及private key,并且将public key添加到服务器端.ssh/authorized_keys文件中(稍后会介绍如何操作)。

3、本地git软件怎么连接linux服务器地址

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 命令 从远程服务器同步仓库

4、linux怎么挂载git服务器

一般来讲需要搭建版本管理和持续集成服务器,版本管理服务器有svn,git等,持续集成服务器有jenkin,hudson等

5、如何搭建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-copy-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的,中间有一部分是怎么去搭建,你可以看下

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

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

7、Linux下有什么好的Git服务器软件

GitLab是利用 Ruby on Rails 一个开源的版本管理系统,实现一个自托管的Git项目仓库,可通过Web界面进行访回问公开的或答者私人项目。它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。在线DEMO

8、如何 连接 linux git服务器

1、前期准备服务器上配置好的gitgit客户端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 命令 从远程服务器同步仓库

9、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.

剩下的推送就简单了。

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

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

与git服务器Linux相关的知识