github 使用

 

1、本地创建ssh key

$ ssh-keygen -t rsa -C "your_email@youremail.com"

  后面的your_email@youremail.com改为你在github上注册的邮箱,成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key

2、回到github上,进入 Account Settings(账户配置),左边选择SSH and GPG keys,New SSH Key,title随便填,粘贴在你电脑上生成的key。

3、验证是否成功,在git bash下输入:

$ ssh -T git@github.com

如果是第一次的会提示是否continue

  输入yes就会看到:You've successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。

4、把本地仓库传到github上去,在此之前还需要设置username和email,因为github每次commit都会记录他们。

$ git config --global user.name "your name"
$ git config --global user.email "your_email@youremail.com"

5、clone git 仓库

$ git clone  git@github.com:path/stocks.git

6、git 常用命令

  1)添加文件到暂存区

  git add <filename>

  git add * 

  git commit -m "代码提交信息"

  2)提交改动到远端仓库

  git push origin master

 
原文地址:https://www.cnblogs.com/junly/p/5970742.html