码云

来源:互联网 发布:西安聚航网络怎么样 编辑:程序博客网 时间:2024/06/06 00:40

创建账号
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.cppgit 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.gitssh方式(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
原创粉丝点击