How do i modify my last commit or a modify my last commit message?



  • man page git commit: http://bit.ly/2oHyDfh

    Word of warning from the man page.

    "At any stage, you may want to undo something. Here, we’ll review a few basic tools for undoing changes that you’ve made. Be careful, because you can’t always undo some of these undos. This is one of the few areas in Git where you may lose some work if you do it wrong."

    It is just something to be aware of, knowing what each command does and the effect of running it has will make you more at ease with it.

    If i made a change to a file, added it to the git repo, and commit it, maybe I wanted to change my commit message or add/change some more files, this can be done with the option --amend.

    If no changes to files were made, it will bring up an text editor to change the commit message. If you wanted to make changes or add files do that first, then run the following commands.

    Keep a note of the commit hash number the top entry.

    $ git log --pretty=oneline
    

    Then:

    $ git commit --amend
    

    This replaces the commit before this one, you can check by running.
    You can see the commit hash will have changed.

    $ git log --pretty=oneline
    

Log in to reply
 

© Lightnetics 2024