git 代码合并

Last updated on September 15, 2024 pm

🧙 Questions

☄️ Ideas

远程分支合并
git merge origin/xxxx

merge分支合并

常用于需要保留pr的所有提交历史,进行代码合并
场景:
F001分支代码合并到demo分支

# 同步远程分支状态
git fetch
# 删除本地分支,防止拉取代码后冲突
git branch -D F001
# 拉取F001分支
git checkout F001
# 操作同上
git checkout demo
# 合并F001分支代码
git merge F001
  • 合并但不创建commitId
git merge branch-a --no-commit
  • 中途退出merge合并
git merge --abort

cherry-pick

指定commit-id进行合并,用于合并部分代码

# 合并a1a8303fe2ddd2aad1ea1f30b2e896f137f46083到590e02b98026e6cca1281fec8256c98f6e887534之间提交的代码
git cherry-pick a1a8303fe2ddd2aad1ea1f30b2e896f137f46083 590e02b98026e6cca1281fec8256c98f6e887534
  • 中止合并
git cherry-pick --abort

合并远程github代码

git clone https://gitee.com/mirrors/next-js.git
git chekout -b ispong
git remote remove origin
git remote add origin https://github.com/ispong/next.js
git remote add upstream https://github.com/vercel/next.js
git fetch upstream
git branch -a
git merge upstream/master
git push origin ispong

git 代码合并
https://ispong.isxcode.com/github/git/git 代码合并/
Author
ispong
Posted on
June 1, 2022
Licensed under