I'm new to using git repositories and phpstorm, i've only been using this for a few months at most.
I'm wanting to know how to push single/specific commits. For example, I made changes to a few files, I've committed those files, and when I go to push those files through phpstorm, it wants to push multiple other commits/changes to the repository as well. I only want to push the single commit I just made though, not the other changes I made before this. So now i'm stuck with a push that I can't actually push yet, and I don't think I can even modify it. I guess my main question is: Why can I choose what I want to commit, but not what I want to push? It just seems like using git through phpstorm is more of a hassle than it is a useful feature at the current time. Do I need to create new local branch every time I plan on doing any project, regardless of the size?
Create a new local branch, e.g. stable
, representing what you want to push:
git branch stable
merge
branches into this, or cherry-pick
individual commits, as required:
git checkout stable
git merge feature-1
git merge master
git cherry-pick 1234abc
push
that branch to your remote:
git checkout stable
git push origin stable
It is important to test your changes together before pushing to your remote, so you can be sure that the set of changes you're making are compatible.
Therefore it might be a good idea to merge stable
into your other branches, e.g. feature-1
and master
, testing there, and then merging back into stable
, which should now give you a fast-forward merge. You may also want to consider rebase
for this.
Some teams use master
as their stable branch, while others use it for active development.