I know there are dozens of questions on this, but I'm having trouble. First off, I'm using Webstorm (IntelliJ) not the command line. Second, this seems to vary by perspective.
I have my master branch, obviously. I created a new branch called "InlineEditing". I've been working in this branch for a couple days. There have been no changes to the master branch. I now want to move all the changes in the current branch back to the master and resume working from there.
In Webstorm, with InlineEditing as the current branch, I tried merging using the following method but it doesn't seem to do anything. Ie, when I then checkout the master branch, it's the old code.
So my question is, what is the proper way to "merge" my current branch back to the master?
To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch.
You normally have two merge use cases.
The standard workflow you are following goes something like this:
git checkout InlineEditing
# work work work
git commit -m 'finished my work'
# now switch to master and merge the feature branch into it
git checkout master
git merge InlineEditing
# resolve any merge conflicts; IntelliJ is great for this step
It might be slightly counterintuitive that you have to switch to master
in order to merge another branch into it. Instead, you might have expected to be able to merge InlineEditing
into master
from the former branch. This is just how Git works.
With regard to your original question about IntelliJ, I think there is nothing wrong with using a GUI tool for Git, provided that you know what you are doing. I tend to do most Git operations from the command line, because I am experienced doing this and the command line is powerful. But there are many cases where I use tools like IntelliJ. For example, resolving merge conflicts is much easier in IntelliJ than the command line. Also, visualizing the history of a branch can be easier using a GUI tool.
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