Setting Up Google Code And Github With Git

建立google code 与github的git 版本控制的代码库

 
先下载并安装好git
github与google code都有git下载
github:https://help.github.com/articles/set-up-git
googlecode:http://code.google.com/p/msysgit/downloads/list
 
#对提交设置默认的名字
$ git config --global user.name "Your Name Here"
 
#设置全局($HOME/.gitconfig)的email信息
$ git config --global user.email "your_email@youremail.com"
 
-------------------------
github
1.检查当前用户目录下有.ssh文件夹;
 
2.如果有.ssh文件夹,就删除(并备份)原来的shh key(包括私钥与公钥以id_rsa*打头的文件);
 
3.在用户当前目录下生成新的ssh key,使用以下命令:
$ ssh-keygen -t rsa -C "your_email@youremail.com"
//指定生成的key的保存目录
Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [回车]
//输入密码与重复密码
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
 
4.将刚生成的公钥文件中的内容复制到剪粘板,再登录github "Add SSH Key"
 
5.完成后使用ssh测试连接github:ssh -T git@github.com
 
--------------------------
google code
1.首先在google code上建立一个git project,clone下来;
 
2.在当前用户目录下使用cmd创建一个.netrc的文件,使用命令:
~> edit .netrc
并添加以下内容,${}中间以自己的用户名与googlecode密码替换:
machine code.google.com login ${username}@gmail.com password ${googlecode_password}
其格式如下:
machine <hostname1>
login <login1>
password <password1>
machine <hostname2>
login <login2>
password <password2>
 
3.设置HOME环境变量(windows)
cmd命令: setx HOME %USERPROFILE% 或
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%
 
4.设置clone的project的remote "origin"的url为:
https://code.google.com/p/some-project/
git bash进入some-project的根目录,使用命令:
git remote set-url origin https://code.google.com/p/some-project/ 
或修改some-project/.git/config文件中的
[remote "origin"]
     fetch = +refs/heads/*:refs/remotes/origin/*
     url = https://bob@code.google.com/p/some-project/
remote "origin"]
     fetch = +refs/heads/*:refs/remotes/origin/*
     url = https://code.google.com/p/some-project/
 

好了,这样修改之后就可以向google code push 了,也可以向github push 了...

原文地址:https://www.cnblogs.com/luowei010101/p/2815181.html