张春 发表于 2024-9-9 10:09:35

WebStorm2024版 将项目上传到gitee

https://img-blog.csdnimg.cn/direct/8bb520a4d3b24887995cf43219f3d06c.png
目录
一、预备
WebStorm
gitee
二、上传代码到Gitee
三、过程中碰到的问题 
报错:You may want to first integrate the remote changes (e.g., 'git pull ...') before pushing again.
报错:fatal: refusing to merge unrelated histories
报错:fatal: Exiting because of unfinished merge.

一、预备

WebStorm

打开WebStorm,点击"更多符号"选择设置,在插件商店中搜索,而且安装插件Gitee(码云),安装完后点“Apply”,再重新打开Version Control就有了。
https://img-blog.csdnimg.cn/direct/7672f17280244c9ba0d2321b247c06a8.png
然后进入“version control”,找到Gitee,登录到Gitee系统登录本身的gitee账号,如下图所示
https://img-blog.csdnimg.cn/direct/2afd30dc83fc4cd795462756ff67d9ca.png
接下来在弹出的 Gitee 登录界面输入账号信息登录到系统,登录成功后,授权给 WebStorm 软件。
https://img-blog.csdnimg.cn/direct/65393b600c374a279684a3016b9bf567.png
在设置中确定 Gitee账户信息,
https://img-blog.csdnimg.cn/direct/3e112aca10c74ad2bd28d48e8a6adc98.png
gitee

(1)必要创建一个堆栈。(此处我创建的堆栈名字是“oj-frontend”)
创建堆栈比较简单,下面两张图就是整个过程,这里不在赘述。
https://img-blog.csdnimg.cn/direct/61d26bf6f9be4e8699e37c775e14db3a.png
https://img-blog.csdnimg.cn/direct/e52eb08a3ed7449aaf2cb8ad02c86588.png

二、上传代码到Gitee

(1)首先添加项目到当地堆栈,这步操尴尬刁难应“git add”命令,
https://img-blog.csdnimg.cn/direct/2880ee4bdd5d40ab99f05b71d7d41145.png
(2)提交项目目录,这步操尴尬刁难应“git commit”命令,
https://img-blog.csdnimg.cn/direct/393e432bf96e403784310a0d47071a17.png
若是初次使用,则必要在WebStorm配置连接到的Gitee上的哪个堆栈。
进入后,可以看到新增加的项目,这个时候还没有堆栈URL,点击 Define remote,将创建的Gitee堆栈所提供的 HTTPS地址复制粘贴到这里。
https://img-blog.csdnimg.cn/direct/9e9c2929ac04410ca882148ec982411e.png
打开webstrom左下角的“git”,可以看到相应的信息,右边就是我们将要提交到堆栈中的文件信息
https://img-blog.csdnimg.cn/direct/8306996ec19e4ddb9ffd3eab4900fdaf.png
(3)推送项目到Gitee,推送你的项目标更改到Gitee上的远程堆栈“oj-frontend”,
https://img-blog.csdnimg.cn/direct/2316597f555d4899833428e59f6ff516.png
https://img-blog.csdnimg.cn/direct/061cb6b162db497b82b0b13e482e1e2b.png
(4)进入我们Gitee中的堆栈,可以看到我们上传上去的项目代码,
https://img-blog.csdnimg.cn/direct/10b87fc07c1a4d69b3360783a6a604fa.png

三、过程中碰到的问题 

报错:You may want to first integrate the remote changes (e.g., 'git pull ...') before pushing again.

https://img-blog.csdnimg.cn/direct/ec2cc374cc5d429e99ccc0b5a6fb2dbd.png
error: failed to push some refs to 'https://gitee.com/xxx/oj-frontend.git'
To https://gitee.com/xxx/oj-frontend.git
!        refs/heads/master:refs/heads/master        (fetch first)
hint: Updates were rejected because the remote contains work that you do
Done
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.

提示:更新被拒绝,因为远程包含您所做的工作
提示:不要在本地使用。这通常是由另一个存储库推送引起的
提示:对于相同的ref。您可能需要首先集成远程更改
提示:(例如,“git pull…”)然后再次按下。
提示:有关详细信息,请参阅“git push --help”中的“关于快进的说明” 原因:这个错误是在尝试推送到 Git 存储库时发生的。错误消息表明,远程存储库包含你当地没有的提交,因此推送被拒绝了。
解决方法:解决这个问题的方法是:

[*] 运行 git pull 命令,将远程存储库中的更改拉取到当地。
[*] 处理任何辩论(如果有的话)。如果远程存储库和当地存储库之间存在辩论,Git 会提示你解决这些辩论。你必要解决这些辩论,然后继承推送。
[*] 一旦你将远程存储库中的更改拉取到当地并解决了可能存在的辩论,再次运行 git push 将你的更改推送到远程存储库。
https://img-blog.csdnimg.cn/direct/4e4f8d53357a4e918a5abaa10a6effbf.png
git pull oj-frontend master
报错:fatal: refusing to merge unrelated histories

场景:运行 上文提到的git pull 命令之后,
git pull oj-frontend master 之后报错, 
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 1.07 KiB | 45.00 KiB/s, done.
From https://gitee.com/xxx/oj-frontend
* branch            HEAD       -> FETCH_HEAD
fatal: refusing to merge unrelated histories 原因:当你看到这个错误 fatal: refusing to merge unrelated histories 时,意味着你正在尝试将两个没有共同汗青的分支举行归并。这通常发生在你的当地堆栈和远程堆栈最初是独立创建的,没有共享任何提交记录。
为相识决这个问题,你可以使用 --allow-unrelated-histories 选项来逼迫 git pull 或 git merge 命令归并两个没有关联汗青的分支。如许做将归并两个分支的汗青,可能必要手动解决归并辩论。
解决方法:
git pull oj-frontend master --allow-unrelated-histories


报错:fatal: Exiting because of unfinished merge.

场景:运行上文提到的命令,
git pull oj-frontend master --allow-unrelated-histories

之后报错,
https://img-blog.csdnimg.cn/direct/d6ed1d57be0c47c1a888a0096ce85429.png
解决方法:为相识决这个问题,你必要先完成或取消当前的归并操纵,然后再执行 git pull 命令。你可以按照以下步骤举行操纵:
(1)首先,取消当前的归并操纵。你可以使用以下命令:
git merge --abort (2)确认取消归并后,你可以提交当前的更改或者将其暂存起来。你可以使用以下命令提交更改,
git commit -m "Your commit message" 或者,如果你想保留更改但暂时不想提交,你可以使用以下命令将更改暂存起来:
git stash (3)当你确认当前没有未完成的归并或者未提交的更改后,再次执行 git pull 命令:
git pull origin master --allow-unrelated-histories 注意:命令里的orgin,在我当地指的是“oj-frontend”。
https://img-blog.csdnimg.cn/direct/c4447ab30b904af69c91fbef9ebd73fa.png
执行结果如下:
https://img-blog.csdnimg.cn/direct/63a89cf0c2f843839263c6cfeb2e41e6.png
OK,成功了。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: WebStorm2024版 将项目上传到gitee