git教程04——用git命令将本地代码提交到github上
2017-07-04 本文已影响76人
Jsonjia
git教程01——windows系统下教科书式安装git
git教程02——详细的git基本操作命令
git教程03——远程仓库
git教程05——克隆github上的代码到本地
如果第一次提交本地代码到github上,在项目根目录(不是项目外面)下,右击选择git bash here,输入
$ git init

这时候本地出现如下:

接着输入命令
$ git add . //如果想添加某个特定的文件,只需把.换成特定的文件名即可

输入命令
$ git commit -m "描述你提交哪些内容"

输入命令,将本地的仓库关联到github上
$ git remote add origin ssh地址 // https地址也行

上传github之前,要先pull一下,执行如下命令:
$ git pull origin master

上传代码到github远程仓库
$ git push -u origin master

好了,没有出现错误说明你提交成功!
查看github,如下:

如果不是第一次提交本地代码到github上,直接在项目根目录下,右击,选择git Bash here,如下

输入如下命令:

然后你去你的github页面查看你的demo,会发现,如下:

说明在AS中用git命令提交代码成功,接下来我打算详细介绍git使用,敬请期待