git 只merge一个commit的方法
2017-03-28 21:08
375 查看
https://git-scm.com/book/tr/v2/Git-Basics-Viewing-the-Commit-History
gil log 来查看commit的记录
Other maintainers prefer to rebase or cherry-pick contributed work on top of their master branch, rather than merging it in, to keep a mostly linear history. When you have work in a topic branch and have determined that you want to integrate it, you move to that branch and run the rebase command to rebuild the changes on top of your current master (or
The other way to move introduced work from one branch to another is to cherry-pick it. A cherry-pick in Git is like a rebase for a single commit. It takes the patch that was introduced in a commit and tries to reapply it on the branch you’re currently on. This is useful if you have a number of commits on a topic branch and you want to integrate only one of them, or if you only have one commit on a topic branch and you’d prefer to cherry-pick it rather than run rebase. For example, suppose you have a project that looks like this:
Figure 80. Example history before a cherry-pick.
If you want to pull commit
This pulls the same change introduced in
Figure 81. History after cherry-picking a commit on a topic branch.
Now you can remove your topic branch and drop the commits you didn’t want to pull in.
gil log 来查看commit的记录
Other maintainers prefer to rebase or cherry-pick contributed work on top of their master branch, rather than merging it in, to keep a mostly linear history. When you have work in a topic branch and have determined that you want to integrate it, you move to that branch and run the rebase command to rebuild the changes on top of your current master (or
develop, and so on) branch. If that works well, you can fast-forward your
masterbranch, and you’ll end up with a linear project history.
The other way to move introduced work from one branch to another is to cherry-pick it. A cherry-pick in Git is like a rebase for a single commit. It takes the patch that was introduced in a commit and tries to reapply it on the branch you’re currently on. This is useful if you have a number of commits on a topic branch and you want to integrate only one of them, or if you only have one commit on a topic branch and you’d prefer to cherry-pick it rather than run rebase. For example, suppose you have a project that looks like this:
Figure 80. Example history before a cherry-pick.
If you want to pull commit
e43a6into your master branch, you can run
$ git cherry-pick e43a6 Finished one cherry-pick. [master]: created a0a41a9: "More friendly message when locking the index fails." 3 files changed, 17 insertions(+), 3 deletions(-)
This pulls the same change introduced in
e43a6, but you get a new commit SHA-1 value, because the date applied is different. Now your history looks like this:
Figure 81. History after cherry-picking a commit on a topic branch.
Now you can remove your topic branch and drop the commits you didn’t want to pull in.
相关文章推荐
- git cherry-pick + commit id 单独merge 任意一个branch的任意一个commit到本branch上
- [Git] Fatal: cannot do a partial commit during a merge
- Git一个诡异错误的解决方法
- Git冲突:commit your changes or stash them before you can merge.
- git Fatal: cannot do a partial commit during a merge
- Git冲突:commit your changes or stash them before you can merge. 解决办法
- git如何合并只有两个commit到一个?
- Git冲突:commit your changes or stash them before you can merge.
- Git冲突:commit your changes or stash them before you can merge.
- Git冲突:commit your changes or stash them before you can merge.
- git修改服务器上前一个提交未merge的代码片段
- Git rebase、pull、push 出现 conflict 后不能merge的解决方法
- git cherry-pick. 如何把已经提交的commit, 从一个分支放到另一个分支
- Hibernate几个常用方法官网释义 save、update、flush、load、merge、persist、delete、commit
- Git commit your changes or stash them before you can merge
- git pull报错:Auto Merge Failed; Fix Conflicts and Then Commit the Result.
- git push 一个分支到服务器上错误的解决方法
- git如何合并只有两个commit到一个
- Git: 合并几个commit为一个commit
- Git pull error:Your local changes to the following files would be overwritten by merge解决方法