git 创建远程版本库(亲测有效)
生活随笔
收集整理的這篇文章主要介紹了
git 创建远程版本库(亲测有效)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、github遠程版本庫
1、創建SSH Key(windows)
- ssh-keygen -t rsa -C "youremail@example.com"
- 2、連接版本庫
git remote add origin git@github.com:ltt2725738034/ll.git
3、克隆版本庫
git clone git@github.com:ltt2725738034/ll.git
4、添加
git add 文件名
5、提交
git commit -m '提示'
6、推到版本庫
git push origin +分支名(master主分支)
二、Linux版本庫
1、創建用戶
useradd ltt
2、 修改密碼
passwd ltt
3、切換到用戶
su ltt
cd
4、創建遠程版本庫
git init --bare ltt.git
5、在Windows下克隆
git clone ltt@192.168.1.182:/home/ltt/ltt.git
終端會讓輸入密碼,此時輸入ltt用戶的密碼即(12345678)
6、為了讓用戶,不用每次都輸入密碼,在linux生成.ssh目錄(win)
ssh-keygen -t rsa -C "youremail@example.com"
7、進入.ssh,新建一個authorized_keys文件
cd /home/ltt/.ssh/
vi authorized_keys
8、打開windows中當前用戶的.ssh/id_rsa.pub,復制里面的內容,粘貼到第7步中的authorized_keys中
9、更改authorized_keys文件的權限
chmod 600 authorized_keys
10、驗證authorized_keys有沒有生效,打開windows
git clone git@github.com:ltt2725738034/ll.git
如果不需要輸入密碼,代表生效了
11、代碼自動更新
cp /home/zph/sample.git/hooks/post-update.sample /home/zph/sample.git/hooks/post-update
12、打開post-update,先清空內容,然后進行編輯如下
#!/bin/bash
#如果想要發送郵件則開啟下面兩行,關于發送郵件請訪問 http://blog.csdn.NET/zph1234/article/details/50509885
#var=`git show` #PHP /var/www/html/mail.php "$var"
cd /usr/share/nginx/html/sample unset GIT_DIR
git checkout master git pull 13、出于安全考慮,只讓克隆提交版本庫,不讓登陸終端 $ which git-shell /usr/bin/git-shellvi /etc/passwd
ph:x:1000:1000:zhangpenghui:/home/zph:/usr/bin/git-shell
總結
以上是生活随笔為你收集整理的git 创建远程版本库(亲测有效)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【天池赛事】零基础入门语义分割-地表建筑
- 下一篇: Vision Transformer 论