Skip to content

Instantly share code, notes, and snippets.

@santosh79
Last active September 27, 2017 21:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save santosh79/9800ffa18012c815b75b to your computer and use it in GitHub Desktop.
Save santosh79/9800ffa18012c815b75b to your computer and use it in GitHub Desktop.

When you begin working on a feature

Step 1: Update the main branch

   git checkout master
   git pull origin master

Step 2: Create a feature branch off of the main branch

   git checkout -b my_feature_branch master

Step 3: Record/Commit your work

   ... make some code changes ...
   git commit -m 'my work' (This is an example - **don't copy paste this**)

Step 4: Keep rebasing your feature branch off the main branch

This will ensure that your feature branch is up-to-date with the main branch and has all of it's code

   git stash
   git checkout master
   git pull origin master
   git checkout my_feature_branch
   git rebase master
   git stash pop

When you are doing the rebase, you may run into merge conflicts. Don't get spooked by merge conflicts. Resolve, them one-by-one and then run git rebase --continue after resolving each merge conflict.

Step 5: You are done

Now you are ready to merge in your changes into the mainline (master branch). Repeat step 4 -- to ensure you have all of the mainline code. Then do:

   git checkout master
   git merge --no-ff my_feature_branch
   git push origin master

If the push fails do git reset --hard origin/master and then repeat Steps 4 and 5.

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