git的一些配置

  1. 云栖社区>
  2. 博客>
  3. 正文

git的一些配置

lovedan 2015-08-21 23:33:00 浏览821
展开阅读全文

git使用socks代理加速

原来git可以配置socks代理的,真好,从github上clone了opencv的代码,基本上是满速了。

首先需要配置shadowsocks,然后通过GUI客户端(或命令行的方式)打开代理进程,chrome上Proxy switchsharp选中shadowsocks

然后要记得配置git的全局代理

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

然后就能高速使用git下载源码了。

用gitolite搭建git服务器

心血来潮的先在本地的fedora-server上装配了起来。

在fedora-server

为什么是gitolite

用gitolite搭建git服务器,作为代码版本控制server。gitolite比较流行,官方文档齐全。

怎样用gitolite搭建git服务器

一台server:我使用fedora22-server

依赖项:perl-devel, git-core, openssh

主要参考git服务器的建立——Git折腾小记

可能遇到的问题:

Can't locate Time/HiRes.pm in @INC (@INC contains: /home/git/gitolite/src/lib /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at /home/git/gitolite/src/lib/Gitolite/Common.pm line 76.

需要安装perl-devel:

sudo dnf install perl-devel

ssh公钥的设定

workstation上的gitolite设定好了,给用户使用的时候,用户每次都输入密码不方便,一个策略是使用ssh-key。通过在客户端上生成rsa的公钥,上传到gitolite-admin这个repo的keydir中,并以用户名.pub形式命名,然后在此repo的conf目录中的配置文件中对指定repo进行读写权限的设定。
具体设定的语法规则,可以去查看gitolite的manual。
值得注意的一点是:在添加rsa的公钥文件后,请git add keydir,否则这个文件没有被track,在配置文件中的配置也就不会生效。

CentOS7下gitolite3的配置

# 先确保添加了epel的repo
yum install gitolite3

然后傻傻的去照/usr/share/doc/gitolite-3/下的readme文档进行配置。妈蛋,又是不负责的文档。配置到各种git config --global后,要git clone gitolite-admin了,一直提示没有权限。ssh-key也添加了阿。糟糕的文档。

还是要google一下。ref

[root@dlp ~]# su - gitolite3
-sh-4.2$ ssh-keygen -f ~/.ssh/gitadmin 
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): # set passphrase
Enter same passphrase again: # confirm
Your identification has been saved in /var/lib/gitolite3/.ssh/gitadmin.
Your public key has been saved in /var/lib/gitolite3/.ssh/gitadmin.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx gitolite3@dlp.server.world
The key's randomart image is:
-sh-4.2$ gitolite setup -pk ~/.ssh/gitadmin.pub 
Initialized empty Git repository in /var/lib/gitolite3/repositories/gitolite-admin.git/
Initialized empty Git repository in /var/lib/gitolite3/repositories/testing.git/
-sh-4.2$ vi ~/.ssh/config
# create new
# any name you like
host GitServer
    user gitolite3
    # Git server's hostname or IP address
    hostname 10.0.0.30
    port 22
    # secret key
    identityfile ~/.ssh/gitadmin
-sh-4.2$ chmod 600 ~/.ssh/config 
-sh-4.2$ git config --global user.name "gitolite3" 
-sh-4.2$ git config --global user.email "gitolite3@server.world" 
-sh-4.2$ git config --global push.default simple
# clone admin repository to finish setup
-sh-4.2$ git clone ssh://GitServer/gitolite-admin 
Cloning into 'gitolite-admin'...
The authenticity of host '10.0.0.30 (10.0.0.30)' can't be established.
ECDSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.30' (ECDSA) to the list of known hosts.
Enter passphrase for key '/var/lib/gitolite3/.ssh/gitadmin':
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.

网友评论

登录后评论
0/500
评论
lovedan
+ 关注