當前位置:首頁 » 雲伺服器 » linux搭建git伺服器搭建

linux搭建git伺服器搭建

發布時間: 2022-02-24 07:37:05

⑴ 如何搭建linux git伺服器與客戶端

1.創建Gitblit安裝目錄 首先我們將在我們的伺服器上建立一個目錄,並在該目錄下安裝最新的Gitblit。 $ sudo mkdir -p /opt/gitblit $ cd /opt/gitblit 創建gitblit目錄 2. 並解壓 現在,我們將從Gitblit官方站點最新版的Gitblit。

⑵ 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伺服器後怎麼使用

linux搭建git伺服器後怎麼使用GitHub就是一個免費託管開源代碼的遠程倉庫。但是對於某些視源代碼如生命的商業公司來說,既不想公開源代碼,又捨不得給GitHub交保護費,那就只能自己搭建一台Git伺服器作為私有倉庫使用。linux搭建git伺服器後怎麼使用

⑷ 如何在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文件中(稍後會介紹如何操作)。

⑸ 如何在Linux上搭建一個Git中央倉庫

本教程只面向那些個人開發者,想要自己在linux上搭建一個git中央倉庫用來上傳發布自己的項目。但是對於團隊來說可能有更高的要求,可以使用gitlab搭建一個可視化的類似github的版本管理系統

⑹ 怎樣在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遠程版本庫

服務端配置
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伺服器

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伺服器,如果使用git

這個簡單,你可以看看廖雪峰的git教程,http://www.liaoxuefeng.com/wiki/我就是在上面學的。花了2天時間,基本上掌握了。
如果你學Linux可以看看劉遄老師的博客www.linuxprobe.com上面還是很多干貨。

⑽ 如何搭建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的,中間有一部分是怎麼去搭建,你可以看下

熱點內容
手機如何設置服務密碼 發布:2024-09-23 08:20:07 瀏覽:542
小兔雲伺服器 發布:2024-09-23 08:15:07 瀏覽:809
vc60是什麼編譯器 發布:2024-09-23 08:12:53 瀏覽:669
如何關掉手機密碼鎖 發布:2024-09-23 07:58:23 瀏覽:487
安卓q區李白哪個市戰力最低 發布:2024-09-23 07:43:12 瀏覽:668
linux的ip設置 發布:2024-09-23 07:41:13 瀏覽:46
ftp在哪裡都可以登錄嗎 發布:2024-09-23 07:35:14 瀏覽:159
機械建模選什麼筆記本配置 發布:2024-09-23 07:25:41 瀏覽:394
怎麼給安卓升級 發布:2024-09-23 07:09:23 瀏覽:245
人類編譯器哪個好 發布:2024-09-23 06:52:24 瀏覽:623