My scenario is that I have one branch in which I've made big improvements to the build process (branch A) and in another I'm working on a unrelated feature (branch B). So now when I'm hacking away at branch B, I want to pull in the stuff I wrote in branch A because I want faster and easier builds. However, I don't want to "pollute" my branch B, just add changes from branchA to unstaged changes.
What I've tried (when standing on branchB):
git merge --no-commit branchA
Doesn't work because it puts you inside a merge. If it didn't, it would be perfect.
git checkout branchA -- .
Doesn't work because it applies changes between branchA..branchB and not the changes master..branchA.
Anything else?
Edit: Yes, changes on branch A are committed. In this example there is only one branch with build improvements, but there may be up to N branches with build improvements that I want to apply while working on a feature branch.
Do a checkout from your current branch and pull from another branch. This pulls all the commits from the other branch into the current branch. You can work on all the changes without changes being committed to actual branch. Optionally you can commit and push if these changes needs to be tracked.
Right-click the branch containing the changes you want and select View History.... Right-click the commit you want to cherry-pick and select Cherry-pick. Visual Studio copies the changes made in that commit into a new one on your current branch.
You can click the Swap Branches link to change which branch is considered as a base against which you are comparing the other branch. on the toolbar . Commit and push the changes. IntelliJ IDEA will copy the entire contents of the file to the current branch.
I just had to do something similar and was able to fix it by adding --squash
to the merge command
git merge --no-commit --squash branchA git reset HEAD # to unstage the changes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With