您的位置:首页 > 运维架构 > Linux

[Linux]本地模拟配置服务器端git仓库

2016-11-08 10:41 399 查看
在本地建立base ,gitA  , gitB;
用base作为服务器端,gitA、gitB作为本地端从服务器中clone和push代码,本地验证是OK的。

以下是我总结的内容:

1、创建 base gitA gitB 三个目录

2、$
cd base

     $ git config --global user.name "Your Name"   //Your Name (是你的计算机名称)

     $ git config --global user.email "youe@example.com"  
//youe@example.com(计算机名称@localhost) 因为本地所以@+localhost才能在git clone时可以成功

3、$
git init

        当git init完成时 使用命令"la"就可以看到目录下存在一个.git文件夹

        『重要』打开.git/config 添加一下内容
[receive]

        denyCurrentBranch = false

下面几步还要注意一下

4、在base目录下

touch A.txt

git status .

git add .

git commit -m "new file"

5、现在gitA目录下

$ git clone archer@localhost:~/AAAAAA/L100    //"~/AAAAAA/L100"是我的服务器段

$ git clone archer@localhost:~/LIU_workspace/base

Cloning into 'base'...

archer@localhost's password:[我的密码]

如果要区分gitA 和base里的提交人需要在

gitA/base$ git config user.name = "A"
gitA/base$ git config user.email = "A@A.com"

这样你在gitA/base$提交代码Author就是:A<A@A.com>啦

现在可以正常的git 操作了!!!

我这里配置是OK的,你们配置的是不是呢?

谢谢!

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: