代码托管地址: https://git.oschina.net (简称github的中文版)
1:在 https://git.oschina.net 注册一个账号
2:添加ssh公钥,使用SSH公钥可以让你的电脑和Git@OSC通讯的时候使用安全连接(git的remote要使用SSH地址)。
3.新建一个项目,如:
4:添加SSH公钥.如图所示:
添加公钥的命令,如下图所示:
SSH Keys
按如下命令来生成sshkey:
ssh-keygen -t rsa -C “[email protected]”
默认地址在于C:\Users\Administrator目录下,复制sshkeys到 公钥标题
cat ~/.ssh/id_rsa.pub
生成公钥标题如上默认地址.
添加后,在终端(Terminal)中输入
ssh -T [email protected]
若返回
Welcome to Git@OSC, huchun!
则证明添加工程.
4 添加公钥到git.oschina中,如图:
一:从https://git.oschina.net上面clone一个项目到本地
1: clone 项目的命令; git clone https://git.oschina.net/huchun/android.git
2: 提交到本地项目服务器,命令如下:
git add . //将代码提交到缓冲区
git commit -m “first name”
git push origin master //提交代码到服务器
接下来按照提示 输入 用户名和密码
如果觉得每次输入密码麻烦,可在.gitconfig 文件中,添加指令.
修改前:’
修改后:
当然在提交中会出现一些问题:
1: error:failed to push some refs to .git
出现这个问题是因为在目录中没有添加README.md文件,因此需要添加
git pull –rebase origin master
2:fatal:unable to connect to eagain.net
出现这问题是从eagain.ney clone时出错
解决方法: git clone https://git.oschina.net/android.git
3:fatal:interactive git shell is not enabled
这个问题需要 sudo vim /etc/passwd
保存修改后,使用如下命令服务器:
ssh git@gitserver
如果还有什么问题,请关注我的公众号,继续交流!