Skip to content

Instantly share code, notes, and snippets.

@withoutwax
Created January 12, 2018 09:56
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save withoutwax/3bcc315f7226bf74bb93b9787410fa98 to your computer and use it in GitHub Desktop.
Save withoutwax/3bcc315f7226bf74bb93b9787410fa98 to your computer and use it in GitHub Desktop.
Guide on how to work with development branch and merge with master

Working with development branch and merge with master

Sometimes you want to experiment with a code which you have on your master branch but not want to save it to master branch. In this case, you can create another branch where you can experiment with ease - and if you are satisfied, you can merge the experiment to the master branch later.

Creating development branch

git branch development
git checkout development
git add .
git commit -m "Initial commit on development branch"
git push origin development

After experimentation


Merging with master

Method 01:

git checkout master
git merge development
git push origin master

Method 02:

This method offers additional steps for safety.

git checkout development
git merge master (resolve any merge conflicts)

git checkout master
git merge development (there shouldn't be any conflicts left over)

or

git merge --no-ff development

... if you want to keep track of who did the merge and when.

@geodeasic
Copy link

Brief and neat. Thanks...

@cfluegel
Copy link

cfluegel commented Aug 3, 2022

Excuse my hopefully just uninformed question as I am new to that branch workflow "master = production ready; development = branch for development". I've read about the different git workflows, but I am not a software developer by trade.
I tried this workflow on one of my repos. The github webpage said that my development branch was x commits behind the master branch, after I did "merged --no-ff development" on the master branch and pushed it to github. I assume I can safely perform the pull/merge from master onto the development branch and it wont affect the work on my development branch, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment