I am relatively new to Git, and I'm still not very comfortable with it. Right now, I'm looking for the command/options/magic that can make the current branch look like another branch; that is, to merge them, but when a conflict arises, to always choose the difference in the branch that is being merged into the current one.
My situation is thus; I have an stable(ish) application on the "master" branch. I also have another branch, called "feature". I basically want to make changes/additions/deletions to feature until I like the new feature I'm working on. Once I feel it is ready, I want to make the master branch look identical to the feature branch.
I know this probably isn't a best practice, but as I said, I'm new to Git. I plan on learning how to do more complicated things in the future, but for now, this is all I need.
Thanks, SO!
The accepted answer ("Branches are just pointers ...") is no good for me, because not only do I need my branch to look like another branch - I need to do so by only adding commits (not losing any of the commits in the current history of my branch).
I liked this approach for making branch A
look like branch B
:
git checkout B
git diff A > patch_to_make_A_like_B
git checkout A
git apply patch_to_make_A_like_B
(And rm patch_to_make_A_like_B
at the end.)
Sorry! Didn't read all the way through before answering...
git checkout master
git merge feature
This will work effortlessly if you have not made any changes to master
since you branched feature
off it.
And what you are trying to do is exactly the way that branching and merging are supposed to work. Develop your features on a branch, when you have it stable and working like you want it to work, merge it back into the master branch.
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