git checkout mastergit pull --rebaseto make sure you have the latest version of mastergit checkout feature/my-branchgit rebase master... to rebase this branch from master- Optionally,
git push --forceto update the branch on github. This is useful for making sure it closes a pull request properly.
- Optionally,
git checkout mastergit merge --no-ff feature/my-branch... merge the branch into master, making sure there's a merge commit
Assuming there have been commits to master since the branch started, here is how the tree would look if just using git merge feature/my-branch
o [master] Merge branch 'feature/my-branch' into master
|\
o | commit to master 3
o | commit to master 2
o | commit to master 1
| o [feature/my-branch] commit to branch 3
| o commit to branch 2
| o commit to branch 1
|/
o commit to master
Or, worse, merge master into the branch then back into master:
o [master] Merge branch 'feature/my-branch' into master
|\
| o [feature/my-branch] Merge branch master into 'feature/my-branch'
|/|
o | commit to master 3
o | commit to master 2
o | commit to master 1
| o commit to branch 3
| o commit to branch 2
| o commit to branch 1
|/
o commit to master
And using rebase:
o [master] Merge branch 'feature/my-branch' into master
|\
| o [feature/my-branch] commit to branch 3
| o commit to branch 2
| o commit to branch 1
|/
o commit to master 3
o commit to master 2
o commit to master 1
o commit to master