将本地的项目上传至GitHub

在上传至GitHub之前
  • 先确保已有自己的GitHub账号

  • 在GitHub中创建一个新的仓库

    在这里插入图片描述
    创建好后
    在这里插入图片描述

第一步
在本地项目更目录中初始化

PS G:\react\reactProject\umi3-antd4> git init
Initialized empty Git repository in G:/react/reactProject/umi3-antd4/.git/

第二步
提交本地代码至本地仓库

git add . // 提交所有文件至暂存区
git commit -m '描述内容' // 将暂存区的文件提交至本地仓库

第三步
首先复制远程仓库地址
在这里插入图片描述
连接远程仓库

 git remote add  <远程仓库地址>

第四步
如果现在向Git上提交代码的话会报一下错误

PS G:\react\reactProject\umi3-antd4> git push -u origin master
To https://github.com/UseGitH/umi.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/UseGitH/umi.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

所以在提交之前我们应该先拉去一下远程仓库的代码,运行命令

git pull --rebase origin master

运行命令后会让我们输入Git的账号秘密

fatal: HttpRequestException encountered.
   发送请求时出错。
Username for 'https://github.com': 
Password for 'https://UseGitH@github.com':

输入账号密码后的结果

From https://github.com/UseGitH/umi
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
warning: unable to access 'mock/.gitattributes': Permission denied
warning: unable to access 'mock/.gitattributes': Permission denied
Applying: 搭建umi3脚手架
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
CONFLICT (add/add): Merge conflict in README.md
Auto-merging README.md
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch' to see the failed patch
Patch failed at 0001 ***
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

然后再运行一下命令,重新拉去一下

git add .
git rebase --continue

第五步
最后运行命令提交本地仓库代码

git push -u origin master
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值