Technology Sharing

  • 首页
  • 资料分享
  • 在线工具
    • 随机密码生成器
  • 介绍
  • RSS
  • privacy
  • 云产品推广
    • 腾讯云
    • 阿里云
Share IT knowledge
  1. 首页
  2. git
  3. 正文

Git强制覆盖分支

2022年8月2日 268点热度 0人点赞 0条评论

背景:使用git进行合作时,有时会建立很多的分支,当分支两两合并完,想将代码移到主分支上时,如果采用merge的方式,往往会有很多冲突。

方法1(假设当前位于test分支)

将test分支强制(-f)推送到主分支master

git push origin test:master -f
git push origin test:master -f

方法2(假设当前位于test分支)

将当前分支切换到主分支

git checkout master
git checkout master

拉取最新代码

git pull
git pull

将主分支重置为test分支                  

git reset --hard test
git reset --hard test

将重置后的master分支强制推送到远程仓库      

git push origin master -f
git push origin master -f

打赏微海报分享
标签: 暂无
最后更新:2022年8月2日

nico

Linux运维工程师 软考网络工程师 && 软考信息安全工程师

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

nico

Linux运维工程师
软考网络工程师 && 软考信息安全工程师

最新 热点 随机
最新 热点 随机
linux部署JDK环境 [Solved] MariaDB import issue: Error at line 1: Unknown command '\-'. Could not retrieve mirrorlist http://mirrorlist.centos.org/ CentOS 7 Kubernetes如何删除卡在“Terminating”状态的命名空间 解决GitLab Runner签名无效 如何禁用 Ubuntu "Daemons using outdated libraries" 弹出窗口
使用 Docker Search 命令的过滤选项来查找容器镜像 使用certbot申请Let’s Encrypt的证书 免费申请HTTPS通配符证书,保障网站安全 [SOLVED] MySQL.. ERROR! The server quit without updating PID file gitlab解锁用户 Rclone:高效、灵活的云存储同步工具
最近评论
woodcockkienzlelsj8o9+73s48g9rr3m0@gmail.com 发布于 10 个月前(07月17日) necessitatibus corporis et odit nam quo harum et c...
RonaldG 发布于 10 个月前(07月07日) Very interesting topic, thank you for putting up.&...
小黑 发布于 1 年前(12月28日) 不错
nico 发布于 2 年前(02月09日) 嘻嘻嘻!!!
Bruse 发布于 2 年前(02月09日) 我来啦!!!
nico 发布于 2 年前(12月10日) 方便查询
Justin 发布于 2 年前(12月10日) 写的很好,谢谢分享!我 Mark 一下~
nico 发布于 3 年前(11月18日) 主题的原因吧
Justin 发布于 3 年前(09月22日) 这篇文章的质量很高呀!写得很详细~ 话说你的文章是隐藏了发布时间吗?
Justin 发布于 3 年前(08月27日) 好家伙,这标题乍一看还以为你打算进军英文技术写作领域了🤓

COPYRIGHT © 2023 Technology Sharing. ALL RIGHTS RESERVED.

备案图标 皖公网安备34132402000202 皖ICP备2023004851号-1