- 使用git在本地创建一个项目,并推送代码到github
// 创建一个项目hello-world
$ makdir ~/hello-world
// 打开这个项目
$ cd ~/hello-world
// 初始化当前文件夹为git目录
$ git init
// 将本地文件添加到缓存
$ git add .
// 提交更新,并注释信息“first commit”
$ git commit -m 'first commit'
// 将缓存中的文件添加到本地仓库,需要在github上事先建好库
$ git remote add origin git@github.com:defnngj/hello-world.git
// 先同步远程和本地目录
$ git pull origin master
// 将本地项目更新到github项目的master分支上去
$ git push -u origin master
- 推送增加的代码到github
git add .
git remote add origin git@github.com:defnngj/hello-world.git
git push -u origin master
参考文章:https://blog.youkuaiyun.com/dengjianqiang2011/article/details/9260435