简体   繁体   English

如何将两个具有特定提交ID的Git分支合并到一个分支中?

[英]How do I merge two Git branches, with specific commit ids, into one branch?

I have two commits: 我有两个承诺:

[branch]: [commit_id]
justin: 94943b74ba273a9f4009
jzbranch: 6070aada7b8a690d410b

How do I merge the two branches, into jzbranch, and resolve any differences between the two? 如何将两个分支合并到jzbranch中,并解决两者之间的任何差异?

How do I merge two Git branches, with specific commit ids, into one branch? 如何将两个具有特定提交ID的Git分支合并到一个分支中?

git checkout jzbranch

git merge [commit_id] jzbranch

or 要么

git merge [commit_id] 6070aada7b8a690d410b

because git allows to merge several branches/commits to one. 因为git允许合并多个分支/提交到一个。

Then run git mergetool or simple git status (in second case you only will see conflict files and then you would open these files with any editor you like). 然后运行git mergetool或简单的git status (在第二种情况下,您只会看到冲突文件,然后可以使用所需的任何编辑器打开这些文件)。 I prefer second way. 我喜欢第二种方式。

After that mandatory make new commit 在该强制性之后进行新的提交

  1. Checkout the jzbranch branch 检出jzbranch分支
    git checkout jzbranch

  2. Merge in justin 合并贾斯汀
    git merge justin

  3. If there are any conflicts, run git mergetool after git mergetool runs, use git commit to commit the final merge. 如果存在任何冲突,请在git mergetool运行之后运行git mergetool ,使用git commit提交最终合并。

git branch newbranch 6070aada7b8a690d410b
git checkout newbranch
git merge 94943b74ba273a9f4009

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将GIT中的2个分支合并到一个带有2个文件夹的分支中 - How do I merge 2 branches in GIT into one branch with 2 folders 如何在Git中将特定提交从一个分支合并到另一个分支? - How do I merge a specific commit from one branch into another in Git? Git将一个分支合并到另外两个分支中 - Git merge one branch into two other branches 如何在一个git commit中将master分支的更改合并到我的side project分支中? - How do I merge a master branch's changes into my side project branch in one git commit? git:如何在分支之间合并,同时保留一个分支独有的变更集? - git: how do I merge between branches while keeping some changesets exclusive to one branch? Git:如何签出提交并将其合并回我的分支? - Git: How do I checkout a commit and merge it back into my branch? 如何提交两个分支的`git diff`? - How do I commit the `git diff` of two branches? 如何创建具有两个分支区别的新git分支? - How do I create a new git branch with the difference of two branches? 如何合并两个 git 存储库和所有分支? - How do I merge two git repositories and all branches? 在git中,如何在分支中提交一个文件但在所有其他分支中忽略? - In git, how to commit one file in a branch but ignore in all the other branches?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM