Git 合并流程:从开发分支到主分支的完整操作

具体流程:先把develop分支合并到你的分支(因为别人可能在develop分支有更改),防止冲突,如果有冲突的话也是在你自己分支上解决掉后提交,然后再切到develop分支,把你的分支合并到develop分支,然后就推送develop分支到git仓库

详细操作步骤

1. 确保当前分支的所有更改已提交

csharp 复制代码
# 查看当前状态(确认没有未提交的修改)
git status

# 如果有未提交的修改,先提交到你的分支(forecast)
git add .
git commit -m "你的提交信息"

2. 获取远程最新代码(确保本地是最新的)

sql 复制代码
git fetch origin

3. 将 develop 分支的更新合并到你的分支

bash 复制代码
# 切换到你的分支(如果不在该分支)
git checkout forecast

# 把 develop 分支的更新合并到你的分支
git merge origin/develop

# 如果有冲突,解决冲突后提交
# git add .
# git commit -m "解决与develop分支的合并冲突"

4. 测试合并后的代码

在你的分支上运行测试,确保合并后的代码没有问题

5. 将你的分支合并到 develop 分支

shell 复制代码
# 切换到 develop 分支
git checkout develop

# 确保 develop 分支是最新的
git pull origin develop

# 将你的分支合并到 develop
git merge forecast

# 如果有冲突,解决冲突后提交
# git add .
# git commit -m "解决合并冲突"

6. 推送更新后的 develop 分支到远程仓库

perl 复制代码
git push origin develop
相关推荐
全栈陈序员12 小时前
Git】从入门到精通(八)—— git log:查看提交历史
大数据·git·elasticsearch
71777716 小时前
Git自建用什么工具比较好:Gitea、Forgejo、GitLab CE与Gitee的选型对比
git·gitlab·gitea
lsc_blog1 天前
年底还在招的岗位,先确认缺口和到岗要求
git·缓存·ci/cd·职场和发展·github
全栈陈序员2 天前
【Git】从入门到精通(十一)—— git reset 三种模式详解
git·elasticsearch
全栈陈序员2 天前
【Git】从入门到精通(十)—— 撤销与恢复:git checkout与git restore
运维·网络·数据库·git
全栈陈序员2 天前
【Git】从入门到精通(五)—— git add:将文件加入暂存区
大数据·git·elasticsearch
全栈陈序员2 天前
【Git】从入门到精通(七)—— git status:查看仓库状态
大数据·git·elasticsearch
莫晓燚2 天前
Ansible 13 个常用模块---企业实战
git·github
无言听风雨丶3 天前
Kubernetes GitOps 持续交付实战:用 Argo CD 让 Git 成为集群事实源
git·elasticsearch·kubernetes
全栈陈序员3 天前
【Git】从入门到精通(六)—— git commit:提交到版本库
大数据·git·elasticsearch