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

gitlinux服务器搭建

发布时间: 2022-01-09 22:21:01

① 如何在linux搭建git远程版本库

服务端配置
1、安装git

2、新建一个用户,只能用来上传代码,而不能通过ssh登录,比如git用户
adser git
chsh -s $(command -v git-shell) git
使用git-shell替换bash ,这样git用户就不能通过ssh登录
这一步会有警告,提示git-shell不在shell列表里,不用担心。

3、添加ssh公钥,在/home/git/.ssh/authorized_keys里添加客户端的公钥,一行一个。
如果没有文件,可以新建
mkdir /home/git/.ssh
touch /home/git/.ssh/authorized_keys

客户端生成公钥的方法是 ssh-keygen,
windows的在C:\Users\用户名\.ssh\ 目录下,打开id_rsa.pub

4、初始化一个空的git仓库
cd /var
git init --bare sample.git
chown -R git:git sample.git
这一步是让目录可以被git用户修改,否则会出现“permission denied”错误。

客户端
1、可以git clone了
git clone git@服务器:/var/sample.git 即服务器上的文件路径
或者ssh,建议ssh,方便设置端口号
git clone ssh://git@服务器:端口号/var/sample.git

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

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

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

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

④ linux怎么搭建git服务器

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

⑤ 怎样在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搭建问题

ip后面加上端口号

  • 需要修改 ssh默认端口

  • 重启ssh服务

  • ssh://[email protected]:32569/opt/data/test.git

  • 客户端拉取的链接如上 类似

希望可以帮助你请采纳谢谢

⑦ 如何搭建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服务器

我们很多人知道Git可能是从Github开始的。因为Github是如此流行,几乎所有写代码的人都知道它,以至于一提到Git就以为是Github,其实两者并没有多少关系,只是名字类似而已(这有点像Java和JavaScript)。
152855_dxab_940492.png

实际上,Git是一个分布式版本控制软件,原来是Linux内核开发者Linus Torvalds为了更好地管理Linux内核开发而创立的。虽然Git比SVN优秀很多,但它们最初被设计出来的想法是一致的,那就是版本控制。而Github却是一个网站,充当Git公共服务器的作用,只要拥有Github账号的人都可以把自己的项目托管在那里,如果你舍不得花些钱,你的项目是强制公开的。所以,Github就是一个通过Git协议为众多开发者提供代码托管的地方,同时它提供了很多特性,第一次使得大家可以这么公开地讨论起各自的项目。

153043_4iw8_940492.png

上面之所以说这么多,是因为今天要讲的Gitosis有点类似Github的功能。什么意思呢?就是我们可以在自己的服务器上安装Gitosis,那么这台服务器就可以向Github一样对外提供代码托管服务了,这对于很多不愿意把自己的代码公诸于世的公司来说最好不过了。

这里以CentOS充当服务器为例给大家讲解一下Gitosis的安装和配置。

1.编译安装git

yum install git

2.安装gitosis

$ yum install python python-setuptools
$ git clone git://github.com/res0nat0r/gitosis.git
$ cd gitosis
$ python setup.py install
网址:https://github.com/res0nat0r/gitosis

3.在开发机器上生成公共密钥(用来初始化gitosis)

$ ssh-keygen -t rsa #不需要密码,一路回车就行(在本地操作)
$ scp ~/.ssh/id_rsa.pub root@xxx:/tmp/ # 上传你的ssh public key到服务器
4.初始化gitosis[服务器端]

$ adser git # 新增一个git用户(先添加用户组 groupadd git)
$ su git # 切换倒git用户下
$ gitosis-init < /tmp/id_rsa.pub # id_rsa.pub是刚刚传过来的,注意放在/tmp目录主要是因为此目录权限所有人都有定权限的
$ rm /tmp/id_rsa.pub # id_rsa.pub已经无用,可删除.
5.获取并配置gitosis-admin [客户端]

$ git clone git@xxx:gitosis-admin.git # 切换到root用户并在本地执行,获取gitosis管理项目,将会产生一个gitosis-admin的目录,里面有配置文件gitosis.conf和一个 keydir 的目录,keydir目录主要存放git用户名
$ vi gitosis-admin/gitosis.conf # 编辑gitosis-admin配置文件
如果无法git clone的话,可以使用git clone git@xxx:/home/git/repositories/gitosis-admin.git

# 在gitosis.conf底部增加

[group 组名]
writable = 项目名
members = 用户 # 这里的用户名字 要和 keydir下的文件名字相一致
# VI下按ZZ(大写)两次会执行自动保存并退出,完成后执行

$ cd gitosis-admin
$ git add .
$ git commit -a -m “xxx xx” # 要记住的是,如果每次添加新文件必须执行git add .,或者git add filename,如果没有新加文件,只是进行修改的话就可以执行此句。
# 修改了文件以后一定要PUSH到服务器,否则不会生效。

$ git push
如果在git push的时候,遇到错误“ddress 192.168.0.77 maps to bogon, but this does not map back to the address – POSSIBLE BREAK-IN ATTEMPT!”,解决为修改/etc/hosts文件,将ip地址与主机名对应关系写进去就可以了。

注意:这里我们并没有进行任何的修改的,现在只有一个管理git的项目。下面的为新添加项目的配置,大家经常用到的也就是下面的操作的。

新建项目

到此步就算完成gitosis的初始化了。接下来的是新建一个新项目到服务器的操作,如第5步中配置gitosis.conf文件添加的是

[group project1] # 组名称
writable = project1 # 项目名称
members = xxx # 用户名xxx一定要与客户端使用的用户名完全一样,否则无权限操作
提交修改并更新到git server服务端

$ git commit -a -m “添加新项目project1,新项目的目录是project1,该项目的成员是xxx“ # “”里的内容自定
$ git push
将新创建的项目提交到git server 上进行登记。以便客户可以操作新项目.

# 在客户端创建项目目录(客户端,当前用户为 XXX )

现在回到开发者客户端,上面创建了一个新项目project1并提交到了git server 。我们这里就创建此项目的信息.注意 项目名称 project1要与gitosis.conf文件配置一致,

$ mkdir /home/用户/project1
$ cd /home/用户/project1
$ git init
$ git add . # 新增文件 留意后面有一个点
$ git commit -a -m “初始化项目project1″
# 然后就到把这个项目放到git server服务器上去.

$ git remote add origin git@xxx:project1.git # xxx为服务器地址
$ git push origin master
# 也可以把上面的两步合成一步

$ git push git@xxx:project1.git master
说明:如果在执行 git push origin master 的时候,提示以下错误:
error: src refspec master does not match any.
error: failed to push some refs to ‘[email protected]:pro2.git’

这是由于项目为空的原因,我们在项目目录里新创建一个文件。经过->add -> commit -> push 就可以解决了

$ touch a.txt
$ git add a.txt
$ git commit -a -m ‘add a.txt’
$ git push
————————————————————————————————

如果在git clone的时候遇到“

error: cannot run ssh: No such file or directory – cygwin git
”错误,则表示本机没有安装ssh命令。安装方法请参考:http://blog.haohtml.com/archives/13313

有时候我们要更换电脑来重新开发项目。这个时候,只需要将id_rsa私钥放在home目录里的.ssh目录里就可以了。

⑨ 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服务器配置

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

热点内容
装缓存下载 发布:2024-09-20 05:42:36 浏览:72
gon引擎自动回收脚本 发布:2024-09-20 05:39:39 浏览:246
好医生连锁店密码多少 发布:2024-09-20 05:09:38 浏览:15
魔兽脚本代理 发布:2024-09-20 05:09:35 浏览:98
python登陆网页 发布:2024-09-20 05:08:39 浏览:757
安卓qq飞车如何转苹果 发布:2024-09-20 04:54:30 浏览:178
存储过程中in什么意思 发布:2024-09-20 04:24:20 浏览:315
php显示数据 发布:2024-09-20 03:48:38 浏览:501
源码安装软件 发布:2024-09-20 03:44:31 浏览:354
入门编程游戏的书 发布:2024-09-20 03:31:26 浏览:236