Update all remotes
git fetch --all
Change to my branch
git checkout my-branch
List changes on my branch not on master
git log origin/master..HEAD --pretty=oneline
3832321972b243f8a4e3b8b86712c4fc515f0514 Updated Dyno volume group check with new nagios service. Removed fh-svc-disk-lvm
fb912c62eb2d4e17995080ef454580a1330317e0 Updated Dyno volume group check with new nagios service. Removed fh-svc-disk-lvm
5eaf51327f305f661221a10ae7882d835cd5bb2a Updated Dyno volume group check with new nagios service. Removed fh-svc-disk-lvm
784b8de5d4981b5cc088b77b62a9d29e8681604d Updated Dyno volumen group check with new nagios service. Removed fh-svc-disk-lvm
4 commits here for a single change, these should be squashed into one.
git rebase -i HEAD~4
Your default editor will open, you change the options on the left of each commit. Set s(squash) for each below the first i.e. Squash all commits into the first one and save (wq!). Note, you can also move commits around during this step, the order that the commits are in the list, is the order that they will be re-applied in. This allows you to squash similar commits that are not necessarily commited in order.
pick 784b8de Updated Dyno volumen group check with new nagios service. Removed fh-svc-disk-lvm
s 5eaf513 Updated Dyno volume group check with new nagios service. Removed fh-svc-disk-lvm
s fb912c6 Updated Dyno volume group check with new nagios service. Removed fh-svc-disk-lvm
s 3832321 Updated Dyno volume group check with new nagios service. Removed fh-svc-disk-lvm
# Rebase 7352ecf..3832321 onto 7352ecf
#
...
You will be asked to sort the description for the commit, delete as appropriate and save again
# This is a combination of 4 commits.
# The first commit's message is:
Updated Dyno volume group check with new nagios service. Removed fh-svc-disk-lvm
Check the result
git log origin/master..HEAD --pretty=oneline
2343e15c7f63923893a79659fa372687ba6a7477 Updated Dyno volumen group check with new nagios service. Removed fh-svc-disk-lvm
You now have one commit instead of four.
You will need to force update your remote branch if you already created one
git push origin my-branch -f
If you are sharing the remote branch with anyone else you will need to inform that they need to reset there local copy of the branch.
git fetch --all
git checkout my-branch
git reset --hard origin/my-branch
Here's the approach in full. We'll assume that we already have a tracking branch 7.x-1.x for the public 7.x-1.x branch.
git checkout 7.x-1.x # Check out the "public" branch
git pull # Get the latest version from remote
git checkout -b comment_broken_links_101026 # topical branch
... # do stuff here.. Make commits.. test...
git fetch origin # Update your repository's origin/ branches from remote repo
git rebase origin/7.x-1.x # Plop our commits on top of everybody else's
git checkout 7.x-1.x # Switch to the local tracking branch
git pull # This won't result in a merge commit
git rebase comment_broken_links_101026 # Pull those commits over to the "public" branch
git push # Push the public branch back up, with my stuff on the top