##TL;DR
git push origin master:refs/heads/development
git checkout --track origin/development
git pull
git checkout -b my_cool_feature
git add .
git commit -m "Commit message"
git checkout development
git pull
git checkout my_cool_feature
git rebase development
git checkout development
git merge my_cool_feature
git push origin development
git branch -d my_cool_feature
##Introduction Lets say you have a project. Project is on GIT. You always have a master branch. Say 2 or 3 developers are working on same project. How do you manage? This document explains the same.
##Strategy
Basic strategy lies in git branching. Basically, you create one branch called DEVELOPMENT
off the master. This branch
will contain all the latest merged code from all the developers. This DEVELOPMENT
branch is where QA will test and allow
to move to production.
##Working You start by making a branch off the development branch. So here is whole summary:
1. Create a new branch of of development named after the feature. 2. Work on my feature, continuously committing at regular intervals to keep track of what I’ve done. 3. Keep local feature branch up to date from any upstream changes my team has made. This needs to happen often to stay fresh. 4. Once finished, wrap all of my tiny commits into a single, pretty commit. 5. Merge local feature branch into development and push it up for the rest of the team. 6. Delete the feature branch, as it is no longer needed.
###Step1 - Setup Remote Branch
git push origin master:refs/heads/development
git checkout --track origin/development
###Step2 - Start working on feature And remember to bring in latest working code before you start your work. Thats what the first line below is doing incase you haven't noticed yet
git pull
git checkout -b my_cool_feature
git add .
git commit -m "Commit message"
###Step3 - Check and get latest working code on development
git checkout development
git pull
###Step4 - Make your changes on top of latest working code
git checkout my_cool_feature
git rebase development
###Step5 - Make interactive rebase
to put all commit history in single commit
git rebase -i development
###Step6 - Merge your branch to development Your branch now have development code + your feature on top of it
git checkout development
git merge my_cool_feature
git push origin development
git branch -d my_cool_feature
###Step7 - Celebrate