github新建本地仓库并将代码提交到远程仓库

方式一:

  1. 在github上新建好仓库:gitTest
  2. 使用命令git clone git@github.com:yourgithubID/gitTest.git,克隆到本地相应的位置
  3. 将要上传的工程代码拷贝到本地的gitTest仓库中
  4. 使用如下命令来将其提交到远程仓库中
1 git add *
2 git commit -m "some info"
3 git push origin master
  • 缺点:需要拷贝,如果提交的工程代码永远不再改变,可以使用该方式,但是如果代码还需要修改再提交,就需要重新将修改后的工程代码拷贝到这个仓库,麻烦且容易出错。

方式二:(推荐)

  1. 在github上手动创建仓库:gitTest
  2. 在本地项目根目录下,cmd进入命令行,使用如下命令来将其提交到远程仓库中
1 git init #初始化本地仓库
2 git add * #添加要push到远程仓库的文件或文件夹
3 git commit -m ‘first commit’
4 git remote add origin https://github.com/yourgithubID/gitTest.git #建立远程仓库
5 git push -u origin master #将本地仓库push到远程仓库

转载自:https://blog.csdn.net/u010412719/article/details/72860193

原文地址:https://www.cnblogs.com/sheldormhh/p/10297912.html