git使用步骤,命令。oschina为例

第一步 生产秘钥

lvyuebindeMacBook-Pro:~ lvyuebin$ ssh-keygen -t rsa -C "[email protected]"

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/lvyuebin/.ssh/id_rsa): lvyuebin // 这里输入秘钥文件名称

 Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in lvyuebin.

Your public key has been saved in lvyuebin.pub.

The key fingerprint is:

SHA256:20gmQbrVtTpD0WXuiiccaOiCAmf7VRJK5hVe+M/QXcE [email protected]

扫描二维码关注公众号,回复: 367054 查看本文章

The key's randomart image is:

+---[RSA 2048]----+

|      o.o...o... |

|     +.+ o.+  E  |

|    + *.o.....   |

|   + * =o....    |

|. o = = S+  .    |

|.+ o . B Oo.     |

|o o . . * +      |

|.  o .   o       |

|    .            |

+----[SHA256]-----+

生成完了后,需要查看来秘钥内容,这样就可以放到oschina,秘钥路径就是上面,当然可以ls下看看文件在不在。查看命令如下:

cat ~/.ssh/lvyuebin.pub

 复制秘钥内容后,打开oschina后台添加一个秘钥,拷贝,保存,输入密码。ps:oschina还会给你发送个邮件

下面继续输入添加链接命令:

ssh-add ~/lvyuebin

正确的返回:Identity added: lvyuebin (lvyuebin)

lvyuebindeMacBook-Pro:~ lvyuebin$ ssh -T [email protected]

The authenticity of host 'git.oschina.net (180.97.163.93)' can't be established.

ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'git.oschina.net,180.97.163.93' (ECDSA) to the list of known hosts.

Welcome to Git@OSC, 大腿哥!

链接完事!下面就可以用了,提交本地用xcode commit,提交到git上用push。

设置git的名称和email,默认好像名字是git

git config –-global user.name "lvyuebin"

git config –-global user.email [email protected]

 

获取git@osc 上的项目路径。

输入命令:cd 项目文件夹

输入命令:git remote add origin [email protected]:datuige/base.git

输入命令:git pull -u origin master //git@osc 上拉取项目

 

输入命令:git push -u origin master //提交项目

猜你喜欢

转载自lvyuebin.iteye.com/blog/2250991