『壹』 如何在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。