git quick tip – branching and merging
Sometimes you want to do experiment work or wants to patch the git master branch with some experimental code, in that case, it’s not the good idea to change the local master branch. Below are steps to do the changes in an experimental branch made with master and merge back to master and the pushback server.
- Create a new branch locally with the existing branch
- Make changes and commit these changes
- Merge them with the local branch from where we have made the branch
- push to the git server.
** # Make a master_dev from master branch
$ git checkout -b master_dev master<br />
# Do changes in master_dev branch
$ git commit -am "Commit message"
# Checkout master branch
$ git checkout master
# Merge the changes of master_dev to master
$ git merge --no-ff master_dev
# Push the changes of master to origin master
$ git push origin master
# Optionally one can push the master_dev branch to remote
# DO ONLY IF YOU WANT MASTER_DEV BRANCH ALSO ON SERVER
$ git push origin master_dev