码云

创建账号
http://git.oschina.net
windows下使用方法
1.下载gitbash工具
https://git-for-windows.github.io/
2.在上传的项目根目录下右键打开gitbash
3.全局设置

git config --global user.name "your name"
git config --global user.email "your email"

4.初始化

git init

5.文件本地仓库上传

git add README.md a/b.cpp
git commit -m "first commit"

—————————————————————————————————————————————————————————————————————————————
6.建立公钥

ssh-keygen -t rsa -C "your email"

然后一路回车,这个会在当前用户文件夹下,生成.ssh 文件夹,里边有个 id_rsa.pub文件,用记事本打开,复制其中的全部内容。
然后打开http://git.oschina.net/keys页面,在该页面中添加公钥,标题可以随便填,公钥就是刚才复制过的内容,然后保存即可
测试

ssh -T git@git.oschina.net
这个地方 问你yes 还是no 的时候 不要点回车,回车就会失败了.而是手动输入 yes才能成功
出现下列warning是正常现象,再一次测试的时候就会通过

The authenticity of host ‘git.oschina.net (120.55.226.24)’ can’t be established.
ECDSA key fingerprint is 27:e5:d3:f7:2a:9e:eb:6c:93:cd:1f:c1:47:a3:54:b1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘git.oschina.net,120.55.226.24’ (ECDSA) to the list of known hosts.

現在的 ssh 使用同樣的方法會出現錯誤訊息

Agent admitted failure to sign using the key

解決方式 使用 ssh-add 指令将私钥 加进来 (根据个人的密匙命名不同更改 id_rsa)

ssh-add   ~/.ssh/id_rsa 

再通过ssh 主机名 就可以实现无密码登录了。

7.添加远程仓库(首先在码云上新建一个项目test,之后输入下列命令)

http方式(每次push都需要密码):git remote add origin https://git.oschina.net/immo-neu/test.git
ssh方式(push不需要密码):git remote add origin git@git.oschina.net:immo-neu/test.git

8.文件远程仓库上传(前提是已经上传到本地仓库)

git push -u origin master

9.不同仓库下的同步

创建本地仓库并提交git clone(自动建立仓库);git add;git commit;
#添加远程仓库:git remote add
同步到本地:git pull -u origin master
同步到远程仓库:git push -u origin master
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值