以下示例基于在centos系统中操作。
服务端:
安装git服务
yum install git-core git-daemon
添加git用户
# add user adduser git # set password for this new user passwd git
在服务端创建空白版本库
# switch current user to git su git # switch pwd to home cd ~ # create repo folder mkdir book.git # create a pure blank repo git --bare init
在客户端创建版本库
# create repo folder cd ~ && create book.git # create the repo git init # setting remote repo git remote add origin git@crzdot.cn:~/book.git # push exchange to server git push origin master
Ok, that's all!
you can clone the repo in another machine by:
git clone git@crzdot.cn:~/book.git
ignore files
Sometimes temporary files and folders will be created and we don't want they enter our git repo. How should we do?
A simple method, you only need create a file with filename .gitignore and log the file or folder. Here is a example:
# filename .gitignore
/_book/
Some other methods will do the same thing. I will add latter.