Git@OSC使用笔记

Git@OSC使用笔记

github非常强大,但是和国内的Git@OSC相比较,其右速度慢,不能免费使用私有库的不足,推荐国内朋友使用。

今天我们就来一次一次性的配置,永久使用,不在到处百度,google各种问题。

注册oschina账号

https://git.oschina.net/signup

安装git

从git-scm.com官网下载最新版git客户端

http://git-scm.com/download/

配置终端显示,有颜色,方便阅读

git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto

设置用户名和用户邮箱

提交代码到Git@OSC时需要用到这些信息,邮箱最好和你注册git.oschina.net的email相同。

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

生成ssh公钥

生成公钥的email和.gitconfig中的email保存一致。

ssh-keygen -t rsa -C "[email protected]"

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xx/.ssh/id_rsa):

这里我们需要输入文件名称,推荐使用如下命名,基本不会出错:
/Users/xx/.ssh/gitosc_rsa

生成.ssh 文件夹,里边有个 gitocs_rsa.pub文件,用记事本打开,复制其中的全部内容(这就是我们需要用到的公钥了)。

添加公钥到Git@OSC

打开http://git.oschina.net/keys页面,在该页面中添加公钥,标题可以随便填,公钥就是刚才复制过的内容,然后保存即可

测试一下是否联通

ssh -T [email protected]
按照提示操作,如果联通,则出现如下信息:
Welcome to Git@OSC, Your Name!

GIT@OSC创建项目

代码托管在在Git@OSC上,那就先在Git@OSC上创建一个空的项目
在http://git.oschina.net/projects/new中添加一个新项目,例如HelloGit。

本地工程纳入git管控

git clone ssh://git.oschina.net/projects/HelloGit.git 
修改部分文件
git add .
git commit -m “HelloGit first commit”

此时工程中的所有文件都以提交到HEAD,但是还没有提交到服务器。

提交代码到Git@OSC仓库

 先在Git@OSC项目中添加一个远程仓库origin
 git remote add origin http://git.oschina.net/yuanlai/HelloGit.git
现在把本地项目master 分支推送到origin仓库

 git push origin master

好了,现在代码以经到了我们的仓库了.
如果要从Git@OSC中克隆项目到本地,可以这么做。

0:首先获取到项目的仓库地址       
1:先cd到用来存放项目的目录下
2:git clone https://git.oschina.net/yuanlai/HelloGit.git

现在代码就到本地了!

你可能感兴趣的:(Git@OSC使用笔记)