当前位置:网站首页>Push the local project to the remote repository
Push the local project to the remote repository
2022-08-01 10:03:00 【ten nine eight seven】
IDEA中推送
The local repository is the same as the remote repository
创建本地仓库
If this step is not set,IDEAwill be displayed in the top menuVCS,而不会显示Git功能
依次打开:文件 | 设置 | 版本控制 | 目录映射;Map the current project path to Git仓库
The English version corresponds to the address:
提交本地项目
将本地项目提交到本地仓库(git add–>git commit);
关联远程仓库
点击Git–>管理远程
英文版对应:
添加远程仓库地址,You can also customize aliases
Pull the remote warehouse project to the local
Git–>拉取(pull)
Select the branch to pull from,如果没有出现,按照提示,多刷新几次
将本地仓库项目推送到远程仓库
Git–>推送(push)
The local repository is inconsistent with the remote repository
If the local repository is inconsistent with the remote repository,Then all local operations are the same as before.The only difference is that various errors will be reported due to the inconsistency between the local repository and the remote repository during the final pull and push.
以防万一,You can create a new temporary branch before proceeding,Make a backup of the local branch
首先是Git拉取失败,报错:
Git 拉取失败
From github.com:ooahz/XXXX
refusing to merge unrelated histories
The reason is naturally because the local library is inconsistent with the remote library. 解决方法: 点击:Git–>更新项目
Choose to merge the current branch
提示无法更新,Follow the prompts to choose the upstream branch,
Also after selecting the branch,选择合并
Then you can see that the remote repository is successfully downloaded to the local,But it is not related to the local project,So we need to merge the projects
Click on the remote repository branch,Then choose any option that will merge the remote branch into the local project branch(My choice here is to merge and pull in)
A warehouse inconsistency message appears,Select Rebase(Rebase)到远程 根据提示,Resolve all conflicts
然后推送即可
使用Git推送
The local repository is the same as the remote repository
创建本地仓库
$ git init
提交本地项目
$ git add .
$ git commit -m "commit"
关联本地项目
$ git remote add origin "远程仓库地址"
Pull the remote project to the local
$ git pull origin master
将本地项目提交到远程仓库
$ git push origin master
The local repository is inconsistent with the remote repository
If the local repository is inconsistent with the remote repository,Then all local operations are the same as before.The only difference is that various errors will be reported due to the inconsistency between the local repository and the remote repository during the final pull and push.The solution is naturally to synchronize the local library and the remote library to be consistent. 图文说明:
以防万一,You can create a new temporary branch before proceeding,Make a backup of the local branch
git pull报错:
fatal: refusing to merge unrelated histories
git push报错:
![rejected]
master -> master (non-fast -forward)
error: failed to push some refs to g1 thub. com: ooahz/webspider.git
或者:
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Here are three solutions:
方法一
和上面的的IDEA的解决方法一样,使用rebae.
$ git pull --rebase origin master
Merge remote repository updates into (pull=fetch+merge)本地库中,rebaseIndicates the last time of the native librarycommittransfer topulllater in the native library
图片说明:
使用该命令后,如有冲突,会提示合并冲突,After manually merging the conflicts, subsequent ones can proceed normallypush操作. Enter the command after merging the conflicts,检查是否完成:
git rebase --continue
然后正常提交
方法二
$ git pull origin master --allow-unrelated-histories
allow-unrelated-historiesIndicates that irrelevant historical commits are allowed,强制合并
It is also necessary to manually merge conflicts during the merge process Enter the command after merging the conflicts,检查是否完成:
git rebase --continue
方法三
$ git push --force origin master
force表示强制提交
边栏推荐
猜你喜欢
阿里腾讯面试一二
Shell: Conditional test action
Get the Token from the revised version of Qubutu Bed
基于CAP组件实现补偿事务与消息幂等性
Node's traditional and advanced practices for formatting time (moment)
Batch大小不一定是2的n次幂!ML资深学者最新结论
VS“无法查找或打开PDB文件”是怎么回事?如何解决
Naive Bayes--Study Notes--Basic Principles and Code Implementation
Meeting OA (Upcoming Meetings & All Meetings)
微信公众号授权登录后报redirect_uri参数错误的问题
随机推荐
退役划水
改版去不图床 Token 的获取
用OpenCV的边缘检测
量化日常工作指标
Comprehensive experiment BGP
ClickHouse入门介绍与其特性
STM32 personal notes - program run and fly
What's up with VS "Cannot find or open PDB file"?How to solve
Yang Hui Triangle (C language implementation)
IntellJ IDEA如何显示换行符(line endings)
SkiaSharp's WPF self-painted five-ring bouncing ball (case version)
堆内存的介绍及应用(含例子)
Android 安全与防护策略
高级驾驶辅助系统ADAS简介
Google Earth Engine——给影像添加一个属性对于单景的时间序列并返回影像
企业微信群:机器人定时提醒功能数据库配置化
scrapy爬虫框架的使用
解决new Thread().Start导致高并发CPU 100%的问题
Three chess (C language implementation)
Go-Excelize API source code reading (8) - GroupSheets(sheets []string), UngroupSheets()