• Skip to main content
  • Skip to primary sidebar

Code Inherit

Simple Programming Code Examples

How to amend previous commit with current changes in git and github?

17th September 2024 by Site Admin Leave a Comment

f you change a page’s text and want to merge it with the previous commit (i.e., not create a new commit but update the existing one), you can follow these steps:

1. Make the Changes

Make the changes you want to the file(s), such as updating the text on the page.

2. Stage the Changes

Stage the changes you just made using:

git add <file>
Replace <file> with the name of the file you modified, or use . to stage all modified files:

git add .

3. Amend the Previous Commit

Now, instead of creating a new commit, you will amend the previous one:

git commit –amend –no-edit

• –no-edit: This flag keeps the previous commit message intact while including your newly staged changes in the previous commit.

4. Push the Amended Commit

Since you are modifying a commit that has already been pushed to GitHub, you will need to force-push the changes:

git push –force

mportant Notes:

• Force-pushing rewrites the history of your repository, so be cautious if you’re working with others, as they will need to pull and reset their branches accordingly.

Filed Under: Uncategorised

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • Bijoy Converter
  • How to amend previous commit with current changes in git and github?
  • How to install PHP 8.1 alongside PHP 7.4 using HomeBrew in MacOs?
  • Create a shell script to switch 7.4 to 8.1 and vice versa
  • How to reflect PHP8.1 to Apache in MacOS?

Recent Comments

    Archives

    • October 2025
    • September 2024
    • January 2024
    • July 2023
    • October 2021
    • September 2021
    • February 2021
    • January 2021
    • October 2020
    • September 2020
    • August 2020
    • May 2020
    • March 2020
    • February 2020
    • January 2020
    • November 2019
    • May 2019

    Categories

    • Couchbase
    • Cron Job
    • dhis2
    • Linux, MySQL
    • MySQL
    • Oracle
    • Oracle Client
    • PHP
    • SSL
    • Subdomain
    • Uncategorised
    • Wordpress
    • WP
    • Zip

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in