GitHub是一个面向开源及私有软件项目的托管平台,那么怎么将本地创建的项目上传到GitHub呢?下面是我的一些心得记录,如有不对,欢迎大家指正更改!
1.登录GitHub账号
没有的话,点击这里注册
2.创建远程仓库
点击New repository创建远程仓库

填写创建仓库的信息

新建好的仓库

3.创建本地项目
如果项目已经创建好了这一步可以省略
4.用终端上传项目到GitHub
cd到本地项目的目录下

git init创建本地git仓库


git add . 或者git add --all将项目中所有的文件添加到暂存区

git commit -m "第一次提交" 提交存放在暂存区的所有项目代码到本地git仓库

git remote add origin 你的远程仓库地址 将本地仓库关联到自己的github上的远程仓库,具体的地址可以按照第三张图上面去复制

git pull --rabase origin master在提交到远程仓库之前,得先把远程仓库更新到本地仓库,比如远程仓库在创建时创建的readme文件.(注意:pull = fetch + merge)

git push origin master或者git push -u origin master将本地更新上传到远程仓库并合并,第一次push时用-u

这个时候就可以在GitHub上对应的仓库中查看到项目已经提交

git tag来查看当前tag, git tag 版本号/git tag -a 版本号 -m “version 版本号” 给项目打tag, git push --tags提交tag到远程仓库

这个时候就可以把地址分享给别人进行查看或者下载了
PS:如果项目有修改的话可以按照下面再次提交的远程仓库并打tag


这个时候就可以通过地址查看或者下载最新代码了

网友评论