git的配置

一、安装git

Windows

从官网下载安装,安装时,在Adjusting your PATH environment页,勾选Run Git from the Windows Command Prompt。


Linux 

Ubuntu:

sudo apt-get install git-core git-gui git-doc gitk


Mac

http://code.google.com/p/git-osx-installer


二、设置git

公共:

git config --global user.name "你的名字"
git config --global user.email "你的邮箱"
git config --global push.default simple
git config --global core.autocrlf false
git config --global gui.encoding utf-8
git config --global core.quotepath off


Windows

git config --global core.ignorecase false 


Mac

git config --global merge.tool "kdiff3"
git config --global mergetool.kdiff3.path /Applications/kdiff3.app/Contents/MacOS/kdiff3


缩写:

git config --global alias.ci commit
git config --global alias.co checkout


连接其他服务器

如果某些库需要连接其他服务器,或使用不同配置,则进到本地repository目录后,执行以下命令:

git config user.name "你的名字"
git config user.email "你的邮箱"

由于没有加“--global”参数,只对本repository有效。

如果之前已经生成过ssh key,则可以复用。


三、配置编辑器

git config --global core.editor "编辑器绝对路径"


四、配置ssh

如果要跟git服务器打交道,还需要设置ssh。

在Linux的命令行下,或Windos上Git Bash命令行窗口中,键入:

ssh-keygen -t rsa -C "你的邮箱"

然后一路回车,不要输入任何密码之类,生成ssh key pair。

如果在Linux上,需要把其中的私钥告诉本地系统:

ssh-add ~/.ssh/id_rsa

再把其中公钥(~/.ssh/id_rsa.pub)的内容复制到git上。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值