Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7091219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:09:26+00:00 2026-05-28T08:09:26+00:00

I have made a git commit and subsequent push. I would like to change

  • 0

I have made a git commit and subsequent push. I would like to change the commit message. If I understand correctly, this is not advisable because someone might have pulled from the remote repository before I make such changes. What if I know that no one has pulled?

Is there a way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:09:27+00:00Added an answer on May 28, 2026 at 8:09 am

    Changing history

    If it is the most recent commit, you can simply do this:

    git commit --amend
    

    This brings up the editor with the last commit message and lets you edit the message. (You can use -m if you want to wipe out the old message and use a new one.)

    Pushing

    And then when you push, do this:

    git push --force-with-lease <repository> <branch>
    

    Or you can use “+”:

    git push <repository> +<branch>
    

    Or you can use --force:

    git push --force <repository> <branch>
    

    Be careful when using these commands.

    • If someone else pushed changes to the same branch, you probably want to avoid destroying those changes. The --force-with-lease option is the safest, because it will abort if there are any upstream changes (

    • If you don’t specify the branch explicitly, Git will use the default push settings. If your default push setting is “matching”, then you may destroy changes on several branches at the same time.

    Pulling / fetching afterwards

    Anyone who already pulled will now get an error message, and they will need to update (assuming they aren’t making any changes themselves) by doing something like this:

    git fetch origin
    git reset --hard origin/master # Loses local commits
    

    Be careful when using reset --hard. If you have changes to the branch, those changes will be destroyed.

    A note about modifying history

    The destroyed data is really just the old commit message, but --force doesn’t know that, and will happily delete other data too. So think of --force as “I want to destroy data, and I know for sure what data is being destroyed.” But when the destroyed data is committed, you can often recover old commits from the reflog—the data is actually orphaned instead of destroyed (although orphaned commits are periodically deleted).

    If you don’t think you’re destroying data, then stay away from --force… bad things might happen.

    This is why --force-with-lease is somewhat safer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a git commit but I have not pushed. And I am
I have made 2 'git commit' locally. But I have not pushed, is it
I have made 2 git commit $ git log commit 9613e1e84b42aeef645977272d310250339cf0e0 commit 01f8699be310f9a56a40835b48a922a879bba24f Each
In my git repo which is tracking a svn repo I have made a
I have made a SVG image, or more like mini application, for viewing graphs
I am using Git on Ubuntu 10.04 (Lucid Lynx). I have made some commits to
I have a project hosted on GitHub and I would like to work locally
I recently screwed up my git repo and would like to find out if
I have successfully made, committed, and pushed changes to a central git repository. I
I have a dev git branch. I made some code changes locally. I haven't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.