====== rebase ======
===== Edit, Move, Delete commits =====
git rebase -i #rewrite all commits in this branch
git rebase -i HEAD~3 # rewrite last 3 commits in this branch
This will open the default text editor with the specified commits.
__NOTE__ that the order differs from the log. This order is chronological from top to bottom.
pick f7f3f6d changed my name a bit
pick 310154e updated README formatting and added blame
pick a5f4a0d added cat-file
# Rebase 710f0f8..a5f4a0d onto 710f0f8
#
# Commands:
# p, pick = use commit
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
Then you can replace all the first word / action at each line, which will make what you want.
* **pick** the commit will be moved where you specify.\\
* **edit** the rebase will be stopped at this commit, making possible to submit any changes to it, adding, removing files, and then you must submit **git commit --amend**, finally then you can edit the message. Finally you must type **git rebase --continue**
* **squash** the commit will be merged with its precedent
===== Change the date of a commit =====
To modify the timestamp of a commit while rebasing:
export newDate="`date`"
GIT_COMMITTER_DATE="$newDate" git commit --amend --no-edit --date "$newDate" && git rebase --continue
Or as a single command:
GIT_COMMITTER_DATE=(date) git commit --amend --no-edit --date "$GIT_COMMITTER_DATE"
===== References =====
* [[http://git-scm.com/book/en/Git-Tools-Rewriting-History|Tools for rewriting history]]
* http://stackoverflow.com/questions/454734/how-can-one-change-the-timestamp-of-an-old-commit-in-git