Show Menu
Cheatography

Git - Feature Branching Cheat Sheet by

Git WorkFlow - Feature Branching

Create new feature branch

git checkout master
git fetch --all
git pull --rebase
git checkout -b feature/####
Always create feature, fix or hotfix branch from master.

Merge into dev or any enviroment branch

git checkout dev
git fetch --all
git pull --rebase
git merge --no-commit --no-ff feature/####
if have merge conflicts resolve them with any tool. Theb:
git commit -m "Merge feature/### into Dev"
git push origin dev
* --no-c­ommit Indicates don't create an inmediate commit.
* --no-ff No fast Fordwards. This keep yout repo history cleaner

Delete branches already on master

git branch -r --merged master
git branch -r | egrep "(*|branch1|branch2)" | sed 's/origin\///' | xargs -n 1 git push origin --delete
* -r includes all remote branches
* "­(*|­bra­nch­1|b­ran­ch2­)" include all branches for first command.

Pull master changes into working branch

git checkout master
git fetch --all
git pull --rebase
git checkout workingbranch
git rebase master
if have merge conflicts resolve them with any tool. 
Then:
git rebase --continue
else
git push origin workingbranch

Create RC Branch

git checkout master
git fetch --all
git pull --rebase
git checkout -b RC/1.0.0.#

/Merge or PR all feature branches for the release/

Reset branch

git checkout working branch
git reset --hard 
git push origin working branch

Recome­nda­tions

Can i merge dev into master?
No
Can i merge two features?
It's not recomm­ended, but if this is a must, yor can create a third branch, witch contains both features
How often must pull master changes?
At least once weeak must pull master changes to all branches
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Git Cheat Sheet
          Bash Dev Cheat Sheet