Sure, being in master branch all you need to do is:
git merge <commit-id>
where commit-id is hash of the last commit from newbranch that you want to get in your master branch.
You can find out more about any git command by doing git help <command>. It that case it's git help merge. And docs are saying that the last argument for merge command is <commit>..., so you can pass reference to any commit or even multiple commits. Though, I never did the latter myself.
Sure, being in master branch all you need to do is:
git merge <commit-id>
where commit-id is hash of the last commit from newbranch that you want to get in your master branch.
You can find out more about any git command by doing git help <command>. It that case it's git help merge. And docs are saying that the last argument for merge command is <commit>..., so you can pass reference to any commit or even multiple commits. Though, I never did the latter myself.
To keep the branching clean, you could do this:
git checkout newbranch
git branch newbranch2
git reset --hard <commit Id> # the commit at which you want to merge
git checkout master
git merge newbranch
git checkout newbranch2
This way, newbranch will end where it was merged into master, and you continue working on newbranch2.
How to merge a specific commit in Git - Stack Overflow
How to merge branch till specific commit id via REST API - Bitbucket Server - The Atlassian Developer Community
question about Commit Id's
How to merge branches to a specific commit
git cherry-pick should be your answer here.
Apply the change introduced by an existing commit.
Do not forget to read bdonlan's answer about the consequence of cherry-picking in this post:
"Pull all commits from a branch, push specified commits to another", where:
A-----B------C
\
\
D
becomes:
A-----B------C
\
\
D-----C'
The problem with this commit is that git considers commits to include all history before them
Where C' has a different
SHA-1ID.
Likewise, cherry picking a commit from one branch to another basically involves generating a patch, then applying it, thus losing history that way as well.
This changing of commit IDs breaks git's merging functionality among other things (though if used sparingly there are heuristics that will paper over this).
More importantly though, it ignores functional dependencies - if C actually used a function defined in B, you'll never know.
You can use git cherry-pick to apply a single commit by itself to your current branch.
Example: git cherry-pick d42c389f
A development team has two separate Merge Requests and when one was merged into the master branch the development team claimed that a second unrelated merge request also got merged at the exact same time. At first I assumed that this was a problem between the keyboard and chair, but after investigating a bit, I noticed that both Merge Requests (different branches) somehow had the same Commit ID. I'm like 99.99% sure that shouldn't happen (as in two branches/merge requests having the same commit id), and that should explain why they merged together, but I want to make sure I'm understanding the problem correctly. Can anyone confirm for me?
I have two branches, main and develop. Lets say that this is my current commit history:
A - B - C - D (main) (tag 1.0.0) - E - F - G (tag 1.0.1) - H (develop)
I want to bring main to G (tag 1.0.1) so that it is one commit behind develop. Note that, I want all commits between main and G to also be included. Would I use cherry-pick or is there a better way?
The git cherry-pick <commit> command allows you to take a single commit (from whatever branch) and, essentially, rebase it in your working branch.
Chapter 5 of the Pro Git book explains it better than I can, complete with diagrams and such. (The chapter on Rebasing is also good reading.)
Lastly, there are some good comments on the cherry-picking vs merging vs rebasing in another SO question.
If BranchA has not been pushed to a remote then you can reorder the commits using rebase and then simply merge. It's preferable to use merge over rebase when possible because it doesn't create duplicate commits.
git checkout BranchA
git rebase -i HEAD~113
... reorder the commits so the 10 you want are first ...
git checkout BranchB
git merge [the 10th commit]
How do I merge two Git branches, with specific commit ids, into one branch?
git checkout jzbranch
git merge [commit_id] jzbranch
or
git merge [commit_id] 6070aada7b8a690d410b
because git allows to merge several branches/commits to one.
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). I prefer second way.
After that mandatory make new commit
Checkout the jzbranch branch
git checkout jzbranchMerge in justin
git merge justinIf there are any conflicts, run
git mergetoolafter git mergetool runs, usegit committo commit the final merge.