下载git

在git官网下载安装包,直接安装
附上官网地址:https://git-scm.com/downloads

github新建项目

进入github首页 新建一个项目
github上传本地项目代码(带图)
填好你的项目名和说明,点击Create respository,就生成了这个项目的git地址
github上传本地项目代码(带图)
项目的git地址
github上传本地项目代码(带图)

本地项目上传master

一、本地项目右键Git Bash Here,进入如下界面
github上传本地项目代码(带图)
二、把github上面的仓库克隆到本地,输入:git clone 项目的git地址,成功后项目会生成一个你的项目名称文件夹;
github上传本地项目代码(带图)
三、cd到你的本地项目根目录下,执行:git init

github上传本地项目代码(带图)

四、将项目的所有文件添加到仓库中,执行:git add --all
github上传本地项目代码(带图)
如果 git status 显示文件都变成绿色,即代表文件添加成功
五、将add的文件commit到仓库,并添加注释语句,执行:git commit -m “注释语句”
github上传本地项目代码(带图)
六、将本地的仓库关联到github上,执行:git remote add origin 之前创建的项目git地址
github上传本地项目代码(带图)
如果出现错误:fatal: remote origin already exists
则执行:git remote rm origin,再执行上面的关联语句即可。
七、将本地代码提交到github项目中,执行:git push -u origin master;会出现弹框填写好自己的邮箱密码就行github上传本地项目代码(带图)
如果出现错误,可以先执行如下命令进行代码合并:git pull --rebase origin master

这样,我们的代码就上传成功了

展示效果
github上传本地项目代码(带图)

相关文章:

  • 2022-01-07
  • 2021-08-11
  • 2021-04-06
  • 2021-06-10
  • 2021-12-17
  • 2021-07-02
  • 2022-01-21
  • 2022-12-23
猜你喜欢
  • 2021-12-05
  • 2021-11-05
  • 2021-08-01
  • 2021-10-26
  • 2021-11-13
相关资源
相似解决方案