给document添加git版本管理

2017-09-02 985点热度 0人点赞 0条评论

首先建立版本库服务端仓库

mkdir ~/gitrepositorys/document
git init

编辑.git/config添加以下内容

[receive]
denyCurrentBranch = ignore

到document目录clone下新的仓库

git clone ssh://wangxianfeng@192.168.2.99:922/volume1/homes/wangxianfeng/gitrepositorys/document/.git

这时候提示如下信息:

fatal: destination path 'document' already exists and is not an empty directory.

通过以下方法解决:
cd /volume1
sudo git clone --no-checkout ssh://wangxianfeng@192.168.2.99:922/volume1/homes/wangxianfeng/gitrepositorys/document/.git/ tmp
然后把tmp目录下的.git文件夹copy到document目录
sudo mv tmp/.git/ document/
删除tmp目录
sudo rmdir tmp

然后到document目录执行如下命令:
sudo git reset --hard【这个命令千万不能随便执行啊,惨痛,记得多commit】
sudo chown -R wangxianfeng:users .git

王显锋

激情工作,快乐生活!

文章评论