build your own git reposity

建立服务器端

从头新建

mkdir gitrepo
chown harriszh:harriszh /home/harriszh/gitrepo
git init --bare /home/harriszh/gitrepo/memtrans.git

基于已有工作区

git clone --bare memtrans memtrans.git

建立客户端

git init
git add .
git commit -m "first commit"
git remote add origin harriszh@sj-harriszh:/home/harriszh/gitrepo/memtrans.git
git push -u origin master

默认每次都要输入密码

可以配置默认的branch

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = harriszh@sj-harriszh:/home/harriszh/gitrepo/memtrans.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

权限

修改repo文件的读写执行权限

chmod g+wx /home/harriszh/gitrepo/memtrans.git

注意点

客户端每次修改时先git pull从服务器端拉回最新修改再进行修改和git push, 这样可以减少很多冲突


harriszh
338 声望131 粉丝

做些有趣的事,留些有用的存在