Bloom Lab
Pages
Home
Bloom Code Guidelines
Thursday, September 24, 2015
Git Tips & Tricks: Change Git Comments (Git Commit message)
## Change Last Commit message To open text editor, allowing you to edit the commit message of the most recent commit: git commit --amend To set the latest commit message directly in the command line: git commit --amend -m "New message of commit" ---- ## Change the Old Commit message If you want to fix the not recent commit or to edit the whole git history use `rebase -interactive`:
1. Make Rebase to commit that older than one to edit: * If u want to **fix several flawed commits**, pass the parent of the oldest one of them: git rebase --interactive e279d09 * If u want to **display a list of the last `n` commits** in your default text editor use the `git rebase -i HEAD~n` command: git rebase -i HEAD~3 * If u want to **edit initial commit** rebase to root: git rebase -i --root 2. Replace `pick` with `reword` in text editor before each commit message you want to change. Before: pick b771d59 Delete CNAME pick 0c39034 Better README pick a7cde4a Change the commit message but push the same commit. # Rebase 9fdb3bd..a7cde4a onto 8cdb6bd # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message #... After: pick b771d59 Delete CNAME pick 0c39034 Better README reword a7cde4a Change the commit message but push the same commit. Text editor will be opened to allow you to change commit message. In each resulting commit file, type the new commit message, save the file, and close it. 3. Force-push the amended commits _(you have to force-push, because of history override)_. git push --force ---- ## see Also * [Git Tips & Tricks: Tagging](http://bloomlab.blogspot.com.ee/2015/09/git-tips-trics-tagging.html) * [Git Tips & tricks](http://bloomlab.blogspot.com.ee/2014/01/git-tips-trics.html) * [Git Basics - Tagging](https://git-scm.com/book/en/v2/Git-Basics-Tagging) * [Keynote: Top JS frmeworks 2015](http://bloomlab.blogspot.com.ee/2015/03/top-javascript-frameworks-2015.html)
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment