We will use $ git commit --amend
here in different ways...
Fixup last commit whithout changing comment:
Git
$ git commit -m 'initial commit'
# added forgotten_config_file
# Do this:
$ git commit -a --amend --no-edit
U'll get only one commit with unchanged commit message and last changes ammended
Edit last commit message:
If u call git commit --amend
at once after the previous commit without any staged changes, then only your comment message of the last commit will be changed.
Git
$ git commit -m 'initial commit'
$ git commit --amend -m 'initial commit - greetings'
As result u will see only one commit in the git log comment "initial commit - greetings".
Add/overwrite changes of the last commit message:
If u want to rewrite your last commit with the new one - stage your modified files at first:
Git
$ git commit -m 'initial commit'
# Do this:
$ git add forgotten_config_file
$ git commit --amend -m 'initial commit with config'
U'll get only one commit with your last changes amended & comment "initial commit with config".
To commit all changes use short form with git commit -a
Git
$ git commit -m 'initial commit'
# added forgotten_config_file
# Do this:
$ git commit -a --amend -m 'initial commit with config'
U'll get only one commit with your last changes amended & comment "initial commit with config".
As you mentioned, the article has an educational viewpoint. It's also useful for a certain purpose. Thank you very much for sharing this. For a cab ride, here are some useful links.
ReplyDeleteBharat Taxi
Taxi Service in India