23
Dec/090
Dec/090
Git merging with removal of one commit
Git grew up to my favorite version control system, I use Git on a daily base now. I like git because it is powerful but also simple for the daily usage. Git is a complex system so there are commands and steps which I do not perform every day. So I write about some more complex steps for later reference.
Today I needed to merge two git branches but remove the changes from only one commit where some files were deleted which should be left untouched in the target branch. I realized that using a temporary local merge branch where I removed the unwanted commit to later merge it with the target branch.
This is the way I merged the two branches:
# Checkout the source branch git checkout nagvis-1.4 # Create a new local git branch for merging git checkout -b master-1.4-merge # Show (for example the last 5) commits in the source branch git show-branch --more=5 nagvis-1.4 # Revert the commit of your choice. In my case it is the commit "nagvis-1.4~2" git revert nagvis-1.4~2 # Checkout the target branch git checkout master # Do the merge git merge master-1.4-merge # Push the changes git push # Remove the temporary branch git branch -d master-1.4-merge



























