Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»GIT»Git – Undo the Last Commit

    Git – Undo the Last Commit

    RahulBy RahulNovember 18, 20151 Min Read

    Sometimes you found that you have committed some wrong files for in-completed code in your local git repository. The following command will revert last commit in your current working repository. If you just want to change last commit message, you can use this article to do it.

    Undo the Last Commit:-

    $ git reset --soft HEAD~
    

    In above command HEAD is a reference to the last commit in the current checked out branch.

    Commit Files Again:-

    Now edit your files and make necessary changes and add them again using git add command. After that commit files as you do always but you can reuse the old commit message using -c ORIG_HEAD. This will open last commit message in editor.

    $ git add ...
    $ git commit -c ORIG_HEAD
    
    git
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install ImageMagick on CentOS & RHEL
    Next Article How to Install PHP Composer on CentOS/RHEL 8/7

    Related Posts

    How To Add a Git Remote Repository

    3 Mins Read

    How to Git Reset to Head

    Updated:November 3, 20213 Mins Read

    How to Delete a File on Git

    3 Mins Read

    How to Git Stash Changes

    Updated:October 29, 20213 Mins Read

    How to delete Git tags

    Updated:October 25, 20211 Min Read

    How to Create Git tags

    Updated:October 25, 20212 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.