Title: Why git commit --amend gives you a brand new commit
Open Graph Title: Why git commit --amend gives you a brand new commit
X Title: Why git commit --amend gives you a brand new commit
Description: git commit --amend folds staged changes and a new message into your last commit. Watch the old commit get replaced on a real repository, and see why the hash changes and what that means once you've pushed.
Open Graph Description: git commit --amend folds staged changes and a new message into your last commit. Watch the old commit get replaced on a real repository, and see why the hash changes and what that means once you've pushed.
X Description: git commit --amend folds staged changes and a new message into your last commit. Watch the old commit get replaced on a real repository, and see why the hash changes and what that means once you've pushed.
Mail addresses
jacob@initialcommit.io
jacob@initialcommit.io
Opengraph URL: https://initialcommit.com/learn/git/commands/git-commit-amend
Domain: initialcommit.com
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "git commit --amend: fixing the last commit in place",
"alternativeHeadline": "Why git commit --amend gives you a brand new commit",
"description": "git commit --amend folds staged changes and a new message into your last commit. Watch the old commit get replaced on a real repository, and see why the hash changes and what that means once you've pushed.",
"image": ["https:\/\/initialcommit.com\/img\/initialcommit\/git-commit-amend-b2f6bdf3.jpg","https:\/\/initialcommit.com\/img\/initialcommit\/git-commit-amend-b2f6bdf3-light.jpg"],
"datePublished": "2026-10-02",
"dateModified": "2026-10-14",
"author": {
"@type": "Person",
"name": "Jacob Stopak",
"url": "https:\/\/initialcommit.com\/blog\/author\/jacobstopak",
"sameAs": ["https:\/\/github.com\/initialcommit-com","https:\/\/www.linkedin.com\/in\/jacob-stopak-6361b4b7","https:\/\/x.com\/initcommit","https:\/\/www.instagram.com\/initialcommit","https:\/\/initialcommit.com"]
},
"publisher": {
"@type": "Organization",
"name": "Initial Commit",
"url": "https:\/\/initialcommit.com",
"logo": { "@type": "ImageObject", "url": "https:\/\/initialcommit.com\/img\/initialcommit\/logo.png" }
},
"mainEntityOfPage": "https:\/\/initialcommit.com\/learn\/git\/commands\/git-commit-amend",
"keywords": "git vcs topic:history",
"inLanguage": "en",
"isAccessibleForFree": true
}
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https:\/\/initialcommit.com" },
{ "@type": "ListItem", "position": 2, "name": "Learn Git", "item": "https:\/\/initialcommit.com\/learn\/git" },
{ "@type": "ListItem", "position": 3, "name": "Git commands", "item": "https:\/\/initialcommit.com\/learn\/git\/commands" },
{ "@type": "ListItem", "position": 4, "name": "git commit --amend: fixing the last commit in place", "item": "https:\/\/initialcommit.com\/learn\/git\/commands\/git-commit-amend" }
]
}
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "Does git commit --amend change the commit hash?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes, always. A commit's hash covers its tree, parent, author, committer and message. Amending changes at least one of those, so the result is a new object with a new hash."
}
},
{
"@type": "Question",
"name": "Can I amend a commit that has been pushed?",
"acceptedAnswer": {
"@type": "Answer",
"text": "You can, but the push will be rejected until you force it, and anyone who already pulled the old commit will have diverged history. Amend before you push, or use git revert afterwards."
}
},
{
"@type": "Question",
"name": "How do I amend without changing the message?",
"acceptedAnswer": {
"@type": "Answer",
"text": "git commit --amend --no-edit."
}
},
{
"@type": "Question",
"name": "How do I undo an amend?",
"acceptedAnswer": {
"@type": "Answer",
"text": "git reflog lists the original commit one entry below the amend. git reset --soft moves the branch back and leaves the amended changes staged."
}
}
]
}
| None | IE=edge |
| theme-color | #ffffff |
| ic-lesson-total | 16 |
| ic-lesson-paths | /learn/git/levels/git-overview,/learn/git/levels/init-and-config,/learn/git/levels/add-and-commit,/learn/git/levels/log-and-status,/learn/git/levels/clone-and-remote,/learn/git/levels/push-and-pull,/learn/git/levels/branch-and-switch,/learn/git/levels/merge,/learn/git/levels/tag,/learn/git/levels/stash,/learn/git/levels/restore,/learn/git/levels/revert,/learn/git/levels/reset,/learn/git/levels/rebase,/learn/git/levels/detached-head,/learn/git/levels/remove-and-rename |
| ic-lesson | /learn/git/levels/remove-and-rename|Level 16: Remove & rename |
| og:type | article |
| og:site_name | Initial Commit |
| og:image | https://initialcommit.com/img/initialcommit/git-commit-amend-b2f6bdf3.jpg |
| og:image:secure_url | https://initialcommit.com/img/initialcommit/git-commit-amend-b2f6bdf3.jpg |
| og:updated_time | 2026-10-14 |
| og:article:published_time | 2026-10-02 |
| og:article:modified_time | 2026-10-14 |
| og:article:author | Jacob Stopak |
| og:article:section | Programming |
| og:article:tag | topic:history |
| twitter:card | summary_large_image |
| twitter:url | https://initialcommit.com/learn/git/commands/git-commit-amend |
| twitter:image | https://initialcommit.com/img/initialcommit/git-commit-amend-b2f6bdf3.jpg |
Links:
Viewport: width=device-width, initial-scale=1.0