『壹』 如何在linux下使用Gitblit工具创建Git仓库服务
Gitblit是郑神销完全开源的,它基于纯粹的java堆栈,被设计以在
Git仓库速度和效率瞎厅方面胜任从小型到极大型的项目。它很容易学习和上手,并有着闪电般的性能。它在很多方面远胜
Subversion、CVS、Perforce和ClearCase等SCM(版本控制)工具,比如,如快速本地分支、易于暂存、多工作流等。
Gitblit的功能
它可以做为一个哑仓库视图,没有管理控制以及用户账户。
它可以做为完整的Git服务,拥有克隆、推送和仓库访问控制。
它能独立于其他喊游Git工具使用(包括实际的Git),它能和您已有的工具协作。
『贰』 linux搭建git远程仓库
1. linux和windows端分别安装git,其中linux中可以用yum安装
[root@node0~]#yum install git
git的默认安装路径在/usr/libexec/git-core
[root@node0 git-core]#cd /usr/libexec/git-core
[root@node0 git-core]#git --version
git version 1.7.1
2.设置linux端git的用户名和密码
[root@node0 git-core]# groupadd git
[root@node0 git-core]# useradd wang -g git
[root@node0 git-core]# passwd wang
New password:
3.在服务器端创建远程仓库
[root@node0 ~]# mkdir -p /mnt/gitrep/wjf
[root@node0 ~]# cd /mnt/gitrep/wjf/
[root@node0 wjf]# git init
Initialized empty Git repository in /mnt/gitrep/wjf/.git/
把仓库所属用户改为wang(git的用户名)
[root@node0 wjf]# chown -R wang:git .git/
注:chown将指定文件的拥有者改为指定的用户或组 -R处理指定目录以及其子目录下的所有文件
4.在windows客户端克隆仓库
$ git clone [email protected]:/mnt/gitrep/wjf/.git
Cloning into 'wjf'...
The authenticity of host '192.168.111.60 (192.168.111.60)' can't be established.
RSA key fingerprint is SHA256:MgWCWF************************1m2tI.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.111.60' (RSA) to the list of known hosts.
[email protected]'s password:
第一次连接远程仓库,出现黑体部分,这是因为Git使用SSH连接,而SSH连接在第一次验证GitHub服务器的Key时,需要你确认GitHub的Key的指纹信息是否真的来自GitHub的服务器,键入yes,然后输入远程仓库的密码就可以了。
5.实际中也通常通过设置公钥的方式来连接远程仓库,这样就不用每次连接都需要密码了。
设置公钥:
1.在windows客户端的gitbash中生成用户私钥和公钥
$ ssh-keygen -t rsa -C "[email protected]"
在c盘用户路径下的/.ssh文件夹下会生成私钥id_rsa和公钥id_rsa.pub
2.linux端
首先 Git服务器打开RSA认证,即,修改/etc/ssh/sshd_config,将其中的以下三项打开
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
然后,将客户端生成的公钥给到服务器端
即,将公钥给到 home/wang(git的用户名)/.ssh/authorized_keys
[root@node0 ~]# cd /home/wang
[root@node0 wang]# mkdir .ssh
[root@node0 wang]# chmod 777 .ssh
[root@node0 wang]# touch .ssh/authorized_keys
在windows客户端的gitbash中 执行:
$ ssh [email protected] 'cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub
然后在linux端:
[root@node0 wang]# chmod 600 .ssh/authorized_keys
[root@node0 wang]# chmod 700 .ssh
[root@node0 wang]# chown wang:git .ssh
[root@node0 wang]# chown wang:git .ssh/authorized_keys
至此,以后再连接远程仓库就不需要密码了。
若仍需要密码,可以查看ssh连接日志/var/log/secure:
常见连接失败原因:Authentication refused: bad ownership or modes for directory /home/wang/.ssh
这时需要检查该目录的所属用户和读写权限等级是否符合要求。公钥以及.ssh文件的权限应该属于git的用户和用户组,读写权限等级.ssh 700,authorized_keys 600.
『叁』 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下使用Gitblit工具创建Git仓库服务
1.创建Gitblit安装目录
首先我们将在我们的服务器上建立一个目录,并在该目录下安装最新的Gitblit。
$ sudo mkdir -p /opt/gitblit$ cd /opt/gitblit
添加新的仓库
使用命令行创建一个新的仓库
touch README.md git init git add README.md git commit -m "first commit" git remote add origin ssh://arunlinoxide@localhost:29418/linoxide.com.git git push -u origin master
请将其中的用户名arunlinoxide替换为你添加的用户名。
在命令行中push一个已存在的仓库
git remote add origin ssh://arunlinoxide@localhost:29418/linoxide.com.git git push -u origin master
注意:强烈建议所有人修改用户名“admin”的密码。
结论
欢呼吧!我们已经在Linux电脑中安装好了最新版本的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的,中间有一部分是怎么去搭建,你可以看下
『陆』 ubuntu虚拟机linux下怎么创建git仓库
一、 在 Ubuntu 系统中部署 Git Server
在Ubuntu系统中,这一步相当简单,只需要在Terminal中输入
sudo apt-get update
完成这一步后,就可以安装 git core 组件,通常情况下,安装在系统中的git 只是一个简单的客户端,包括一些最基本的命令以及特性,而作为保管代码的仓库,则还需要其他特性支持,所以需要安装 git core,如果之前已经安装了 git,那么仍然需要安装 git core
sudo apt-get install git-core
二、配置Git Server
完成这两步之后,就可以开始配置 Git Server 了。
增加 developers 组以及创建保存项目的仓库
需要创建一个新的用户组,并且将创建的仓库都放置在名为 git 的用户下,当然git 要隶属于 developers 组,这样也是为了方便将来的管理需要。
sudo groupadd developers
cd /home/
sudo mkdir git
sudo useradd git -d /home/git
以上四个命令分别为创建 developers 用户组, 并在/home/ 文件夹下为名为 git 的用户创建工作目录,创建名为 git 的用户账户并将它的工作目录指向/home/git。
之后,需要将增加的用户添加到 developers 用户组中,这一步一般通过修改/etc/group 文件达成,在正式修改 /etc/group 文件前或许需要先做一个备份。找到创建的用户组,譬如例子中创建的 developers。或许能在文件中看到类似的一行:
『柒』 如何在Linux下使用Gitblit工具创建Git仓库服务
1.创梁袭建Gitblit安装目录
首先我们将在我们的服务器上建立一个目录,并在该目录袭则下拍渣棚安装最新的Gitblit。
$ sudo mkdir -p /opt/gitblit
$ cd /opt/gitblit
创建gitblit目录
『捌』 linux能搭建maven仓库吗
对Linux及Maven都不熟悉,在网上折腾,然后总结如下:
一.搭建仓库(JDK required):
linux platform, IP:192.168.2.99
1.download apache-maven-x.x.x-bin.tar.gz
2.download nexus-oss-webapp-x.x.x.x-bundle.tar.gz
3.tar -zxvf apache-maven-x.x.x-bin.tar.gz -C /usr/java/
4.add enviroment variable:
a. vi /etc/profile;
b. append 'MAVEN_HOME=/usr/java/***'
c. append 'PATH=${PATH}:${MAVEN_HOME}/bin'
d. append 'export MAVEN_HOME PATH'
e. source /etc/profile
5.tar -zxvf nexus-oss-webapp-x.x.x.x-bundle.tar.gz -C /usr/java/
6.startup(shutdown) nexus:
a. cd nexus/nexus-oss-webapp-1.9.0.2/bin/jsw/linux-x86-32/
b. ./nexus start(stop)
7.test:
http://localhost:8081/nexus
ok, login as admin/admin123 (default)
二、使用Mavan仓库:
windows platform, IP:192.168.2.3
1.download and setup apache-maven-x.x.x-bin.zip (D:/maven)
2.add enviroment variable:
new MAVEN_HOME:D:/maven
add to path:%MAVEN_HOME%/bin
test:mvn -version, ok
3.open the file "settings.xml " under the folder "d:/maven/conf"
add the next chars into the file:
<localRepository>C:/.m2/repository</localRepository>
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<name>linux-nexus</name>
<url>http://192.168.2.99:8081/nexus/content/groups/public</url>
<id>nexus</id>
</mirror>
</mirrors>
<profiles>
<profile>
<id>dev</id>
<repositories>
<repository>
<id>nexus</id>
<url>http://192.168.2.99:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<url>http://192.168.2.99:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
save, ok.
4.mkdir "d:/workspace"
5.mvn archetype:generate
6.choose the default selection(16)
7.input some informations(the project name:helloworld)
8.ok, look the dir "D:/workspace", there is a folder "helloworld"
9.open the file "pom.xml " under "helloworld", add some dependencies, example:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6.SEC02</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
10.run the command "mvn install " under "helloword", then, it will download some jars and poms
into "C:/.m2/repository"(default) from 192.168.2.99.
11.convert this maven project to eclipse project:
under the folder "helloworld", run "mvn eclipse:eclipse ".
说明:192.168.2.99是虚拟机中Linux的IP,192.168.2.3是虚拟机中Win7的IP。