First things first! Get a log of your latest commits using:
$ git log --oneline
You will see something like this in your terminal:
f46cab5 Add default layout for Home #6 - Add statics for default layout 17c75ce Add notes for an selenium issue and its solution #3 3ae1ca8 Refactor home page view to use a template #5 a3a8b68 Add portfolio home view #5 981d904 Add UT for home_page view #4 ...
Hm, this is an one line log for your projects commit history. That is because we used the option
--oneline when we asked git to log for us.
Now we have our log we can rebase:
$ git rebase --interactive commit_hash^
Use the editor of your choice - Vi, Nano etc - you change the words
For the commits you want to change, save and quit. Then git will prompt you with each commit that you marked as reword so you can change the commit message.
Writing the following command i am asking to rebase the last 3 commits starting from the comming witch has the speicified hash:
$ git rebase --interactive f46cab5^^^
GNU nano 2.2.6 File: ...ilerplate/.git/rebase-merge/git-rebase-todo pick 3ae1ca8 Refactor home page view to use a template #5 pick 17c75ce Add notes for an selenium issue and its solution #3 pick f46cab5 Add default layout for Home #6 - Add statics for default layout -$ # Rebase a3a8b68..f46cab5 onto a3a8b68 # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out
Each commit message you have to save and quit to go to the next commit message
EDIT: to navigate in vim you use j to go up, k to go down, h to go left, and l to go right( all this in NORMAL mode, press ESC to go to NORMAL mode ). To edit a text, press i so that you enter the INSERT mode, where you insert text. Press ESC to go back to NORMAL mode :)
Now if you wont to push your commits in Github you should use the
$ git push --force
$ git push --force does is overwrite the remotes commits with your local commits.