1 安装git

yum -y install git

2 建立git用户

useradd -s /usr/bin/git-shell git

3 创建证书登录,方便提交版本

cd /home/git/
mkdir .ssh
vi .ssh/authorized_keys
# 把本地用户的公钥加进来
chown git:git -R .ssh
chmod 700 .ssh
chmod 600 .ssh/authorized_keys

4 创建仓库

mkdir test.git
cd test.git/
git --bare init

chown git:git -R test.git

5 本地下载并提交

aquan:git hqlulu$ git clone git@server.domain:/path/to/test.git
Cloning into 'test'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
aquan:git hqlulu$ cd test/
aquan:test hqlulu$ vi a.txt
aquan:test hqlulu$ git add a.txt
aquan:test hqlulu$ git commit -m test
[master (root-commit) 14d99af] test
1 file changed, 1 insertion(+)
create mode 100644 a.txt
aquan:test hqlulu$ git push
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git@server.domain:/path/to/test.git'
aquan:test hqlulu$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 198 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To server.domain:/path/to/test.git
* [new branch]      master -> master


6 备份本地库到远程并且添加远程库同步

#复制本地库镜像,比如这个Xcode项目刚开始只是本地git库
git clone --mirror ~/Xcode/ABC/
Cloning into bare repository 'ABC.git'...
done.

#同步文件到服务器,也可以是别的方式
rsync -av ABC.git server.domain::DIR/

#回到本地项目,添加远程库
git remote add origin git@server.domain:/path/to/ABC.git




原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
Tags: ,
发表评论
AD
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML 打开UBB 打开表情 隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写
 

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐