1. 登录github,新建一个仓库

Github 从本地上传项目


Github 从本地上传项目

点击 create repository 创建

Github 从本地上传项目

2.到本地项目根目录下,右键,点击 git base here (需要安装git客户端)

打开git命令台

Github 从本地上传项目


3. git init  

会创建一个 .git的文件夹

大概意思----将项目交给git管理

Github 从本地上传项目

Github 从本地上传项目


4. git add .              ------将文件添加到仓库中,注意不要漏了 点   .   

    git commit -m "提交说明"    ----- 提交

Github 从本地上传项目


5. 将本地的仓库 关联到 远程仓库

    5.1 获取远程仓库路径(前面步骤,在github上新建的仓库路径)

Github 从本地上传项目

    5.2 本地仓库与远程仓库关联

    git remote add origin https://github.com/SkyAndSun/ml_algorithnic.git     

    此处的 https://github.com/SkyAndSun/ml_algorithnic.git     为自己远程仓库的地址

Github 从本地上传项目


6.最后就是推送 本地代码 到远程仓库

    推送之前,需要先拉取远程仓库的代码,避免冲突

git pull origin master

效果如下:

Github 从本地上传项目


执行推送操作,此操作需要输入 github的用户名和密码

git push -u origin master

Github 从本地上传项目


成功之后刷新 github,会将本地代码添加到github上面

Github 从本地上传项目


----------------------------------------

可能出现的问题

error: failed to push some refs to 'https://github.com/SkyAndSun/ml_algorithnic.git

Github 从本地上传项目

是因为,创建仓库的时候里面的README文件不在本地仓库目录中,这时要先将此内容拉取下来并合并到本地仓库中:

解决方案,先拉取下来 合并,然后再次 推送上去

git pull --rebase origin master

git push -u origin master

Github 从本地上传项目

相关文章:

  • 2021-06-18
  • 2021-05-13
  • 2022-12-23
  • 2021-07-19
  • 2021-08-01
猜你喜欢
  • 2021-11-05
  • 2021-08-01
  • 2021-10-26
  • 2021-11-13
  • 2021-09-14
相关资源
相似解决方案