Something I often find myself doing is, "Rebase a feature branch, merge it & delete it." To do that I run:
git rebase master feature
git checkout master
git merge feature
git branch -d feature
That seems quite laborious for something I'd imagine to be a common workflow. Does anyone know a faster way?
(Obviously I could write a script, but I'm wondering if there's a built-in approach I've missed.)
Once the feature is complete, the branch can be merged back into the main code branch. First we run git checkout master to change the active branch back to the master branch. Then we run the command git merge new-branch to merge the new feature into the master branch.
Git Flow is the most widely known branching strategy that takes a multi-branch approach to manage the source code. This approach consists of two main branches that live throughout the development lifecycle.
Build your strategy from these three concepts: Use feature branches for all new features and bug fixes. Merge feature branches into the main branch using pull requests. Keep a high quality, up-to-date main branch.
GitHub Flow is a simpler alternative to GitFlow ideal for smaller teams as they don't need to manage multiple versions. Unlike GitFlow, this model doesn't have release branches.
The general approach remains scripting or defining aliases, as illustrated in "Streamline your git workflow with aliases", except you might need a parameter as in "git alias with positional parameters":
rebmrg = "!f() { git rebase master $1; git checkout master ; git merge $1 ; git branch -d $1 }; f"
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