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.
git checkout master git merge --no-ff my_feature_branch git push origin master
push fails do
git reset --hard origin/master and then repeat Steps 4 and 5.