{"id":3615,"date":"2026-06-06T10:41:21","date_gmt":"2026-06-06T08:41:21","guid":{"rendered":"https:\/\/deepdocs.dev\/?p=3615"},"modified":"2026-06-28T19:07:05","modified_gmt":"2026-06-28T17:07:05","slug":"git-commit-amend","status":"publish","type":"post","link":"https:\/\/deepdocs.dev\/git-commit-amend\/","title":{"rendered":"Git Commit Amend: Rewrite Git History Safely"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You&#8217;ve done it before. You make a commit, hit enter, and then notice the commit message has a typo, a file is missing, or a tiny fix should have been included with the change you just recorded.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s the moment <code>git commit --amend<\/code> earns its place in a professional workflow. Used well, it keeps your history clean, your pull requests easier to review, and your branch readable when someone has to trace a regression later.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A few practical takeaways matter up front:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Use Git commit amend for the most recent commit only.<\/strong><\/li>\n\n\n\n<li><strong>Stage what you want first<\/strong>, then amend.<\/li>\n\n\n\n<li><strong>Treat local history as editable draft history.<\/strong><\/li>\n\n\n\n<li><strong>Treat shared history as published record.<\/strong><\/li>\n\n\n\n<li><strong>Know the recovery path before you rewrite anything.<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"has-xx-large-font-size wp-block-paragraph\"><strong>Table Of Contents<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/deepdocs.dev\/git-commit-amend\/#mastering-git-commit-amend-for-cleaner-history\" class=\"wp-block-table-of-contents__entry\">Mastering Git Commit Amend for Cleaner History<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/git-commit-amend\/#common-scenarios-for-amending-your-last-commit\" class=\"wp-block-table-of-contents__entry\">Common Scenarios for Amending Your Last Commit<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/git-commit-amend\/#the-golden-rule-never-amend-public-history\" class=\"wp-block-table-of-contents__entry\">The Golden Rule Never Amend Public History<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/git-commit-amend\/#how-to-push-amended-commits-and-recover-from-mistakes\" class=\"wp-block-table-of-contents__entry\">How to Push Amended Commits and Recover from Mistakes<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/git-commit-amend\/#when-to-use-interactive-rebase-instead\" class=\"wp-block-table-of-contents__entry\">When to Use Interactive Rebase Instead<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/deepdocs.dev\/git-commit-amend\/#amending-commits-a-tool-for-discipline\" class=\"wp-block-table-of-contents__entry\">Amending Commits A Tool for Discipline<\/a><\/li>\n<\/ul>\n\n\n\n<h2 id=\"mastering-git-commit-amend-for-cleaner-history\" class=\"wp-block-heading\">Mastering Git Commit Amend for Cleaner History<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/cdnimg.co\/c5154994-a2fe-43c0-a286-28e433de4fd1\/e1d546ac-7905-4942-8e07-1dba6ae39605\/image.jpg?ssl=1\" alt=\"Mastering Git Commit Amend for Cleaner History\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Good teams care about commit history because commit history becomes operational history. When an incident happens, when a release needs a selective revert, or when a maintainer wants to understand why a change landed, the shape of the history matters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>git commit --amend<\/code> is the fastest way to clean up the last commit before that history leaves your machine. It&#8217;s not a trick. It&#8217;s normal Git hygiene.<\/p>\n\n\n\n<h3 id=\"what-amend-is-good-at\" class=\"wp-block-heading\">What amend is good at<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The command is a strong fit when the latest commit is almost right but not quite finished.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Typical examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Message cleanup<\/strong> when the commit text is vague, noisy, or wrong<\/li>\n\n\n\n<li><strong>Forgotten files<\/strong> that belong with the same logical change<\/li>\n\n\n\n<li><strong>Minor corrections<\/strong> that don&#8217;t justify a follow-up \u201cfix typo\u201d commit<\/li>\n\n\n\n<li><strong>Metadata fixes<\/strong> such as author or signing adjustments<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Practical rule:<\/strong> If the previous commit and the missing fix would be reviewed, reverted, and understood as one unit, amending is usually the right move.<\/p>\n<\/blockquote>\n\n\n\n<h3 id=\"why-senior-engineers-use-it\" class=\"wp-block-heading\">Why senior engineers use it<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">I usually explain amend as pre-publication editing. You&#8217;re tightening the record before anyone else depends on it. That&#8217;s different from hiding mistakes. It&#8217;s about presenting a branch that tells the truth in the fewest, clearest steps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That distinction matters because Git doesn&#8217;t \u201cedit\u201d the old commit in place. The Git documentation describes <code>git commit --amend<\/code> as the standard way to rewrite the most recent commit, and notes that saving the amended commit creates a <strong>new commit object<\/strong> rather than modifying the original one in place, which means the previous tip is effectively replaced with a commit that has a different identity in history, as explained in <a href=\"https:\/\/www.atlassian.com\/git\/tutorials\/rewriting-history\">Atlassian&#8217;s guide to rewriting Git history<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you remember only one thing, remember this: amend is clean and useful precisely because it rewrites history. That power is why it helps, and also why it can hurt.<\/p>\n\n\n\n<h2 id=\"common-scenarios-for-amending-your-last-commit\" class=\"wp-block-heading\">Common Scenarios for Amending Your Last Commit<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/cdnimg.co\/c5154994-a2fe-43c0-a286-28e433de4fd1\/7ccdf6ed-f8d8-49c3-a833-06e236b0250c\/image.jpg?ssl=1\" alt=\"Common Scenarios for Amending Your Last Commit\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The everyday workflow is simple. Stage the exact content you want, then amend the last commit. The Git book puts it plainly: stage corrected files with <code>git add<\/code> or <code>git rm<\/code>, run <code>git commit --amend<\/code>, and Git uses the current staging area to create a new commit object that replaces the previous tip, while the old commit may still be recoverable through reflog, as documented in the <a href=\"https:\/\/git-scm.com\/book\/id\/v2\/Git-Tools-Rewriting-History\">Git book section on rewriting history<\/a>.<\/p>\n\n\n\n<h3 id=\"fix-a-bad-commit-message\" class=\"wp-block-heading\">Fix a bad commit message<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This is the cleanest use case. No code changes, just a better message.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> commit <span class=\"tok-propertyName\">--amend<\/span><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Git opens your editor with the previous message. Rewrite it, save, and close.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use this when the original message is too generic, references the wrong ticket, or doesn&#8217;t match the actual change. A strong message saves reviewers time and helps future you during <code>git log<\/code>, <code>git blame<\/code>, or release prep.<\/p>\n\n\n\n<h3 id=\"add-forgotten-files-without-changing-the-message\" class=\"wp-block-heading\">Add forgotten files without changing the message<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This is probably the most common real-world amend.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> add path\/to\/missing-file<\/div><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> commit <span class=\"tok-propertyName\">--amend<\/span> <span class=\"tok-propertyName\">--no-edit<\/span><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><code>--no-edit<\/code> keeps the existing message. That&#8217;s what you want when the commit description is already correct and you only forgot to include part of the implementation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you need a refresher on the basic staging and commit flow before you clean it up with amend, this guide on <a href=\"https:\/\/deepdocs.dev\/how-to-commit-to-github\/\">how to commit to GitHub<\/a> is a useful baseline.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After that, the same pattern works for removed files too:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> <span class=\"tok-variableName\">rm<\/span> path\/to\/file<\/div><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> commit <span class=\"tok-propertyName\">--amend<\/span> <span class=\"tok-propertyName\">--no-edit<\/span><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<h3 id=\"make-a-small-code-correction\" class=\"wp-block-heading\">Make a small code correction<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Sometimes the tests fail right after commit because of a tiny oversight. Don&#8217;t pile on a throwaway follow-up commit if the change clearly belongs in the last one.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-comment\"># edit files<\/span><\/div><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> add path\/to\/fixed-file<\/div><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> commit <span class=\"tok-propertyName\">--amend<\/span> <span class=\"tok-propertyName\">--no-edit<\/span><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">That keeps the branch focused. Reviewers see one coherent change instead of a noisy pair like \u201cadd feature\u201d followed by \u201cfix import.\u201d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A quick walkthrough helps if you want to see the mechanics in action:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><iframe width=\"100%\" style=\"aspect-ratio: 16 \/ 9;\" src=\"https:\/\/www.youtube.com\/embed\/ElRzTuYln0M\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen=\"\"><\/iframe><\/p>\n\n\n\n<h3 id=\"correct-author-information\" class=\"wp-block-heading\">Correct author information<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This matters in pair sessions, worktree mix-ups, or when global Git config wasn&#8217;t what you expected.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> commit <span class=\"tok-propertyName\">--amend<\/span> <span class=\"tok-propertyName\">--author<\/span><span class=\"tok-operator\">=<\/span><span class=\"tok-string\">&quot;Correct Name &lt;correct@example.com&gt;&quot;<\/span><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Open the editor if you also want to revise the message, or combine it with <code>--no-edit<\/code> if the text is already right.<\/p>\n\n\n\n<h3 id=\"add-a-signature-or-repeat-the-amend-cycle\" class=\"wp-block-heading\">Add a signature or repeat the amend cycle<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can also reissue the last commit with signing enabled.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> commit <span class=\"tok-propertyName\">--amend<\/span> <span class=\"tok-propertyName\">-S<\/span><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">And yes, you can amend multiple times before pushing. That&#8217;s normal on a draft branch.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">A branch under active local cleanup is still draft work. A branch others may pull from is no longer draft work.<\/p>\n<\/blockquote>\n\n\n\n<h2 id=\"the-golden-rule-never-amend-public-history\" class=\"wp-block-heading\">The Golden Rule Never Amend Public History<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/cdnimg.co\/c5154994-a2fe-43c0-a286-28e433de4fd1\/7b04adf7-ff45-4eed-ad86-b0c3f9b7fc9b\/image.jpg?ssl=1\" alt=\"The Golden Rule Never Amend Public History\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once a commit is pushed to a shared branch and another developer has based work on it, that commit stops being just yours. It becomes part of the team&#8217;s working record.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Amending public history breaks expectations because collaborators now have one version of the branch, while you&#8217;ve created another. Git can&#8217;t pretend those are the same commit because they are not the same object anymore.<\/p>\n\n\n\n<h3 id=\"what-goes-wrong-in-practice\" class=\"wp-block-heading\">What goes wrong in practice<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The damage usually shows up as friction, not drama at first:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pull confusion<\/strong> when teammates fetch a rewritten branch tip<\/li>\n\n\n\n<li><strong>Rebase churn<\/strong> because local work now sits on top of a commit that no longer exists on the remote<\/li>\n\n\n\n<li><strong>Harder incident response<\/strong> when people are unsure which version of history is canonical<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s why I tell teams to think of a pushed shared branch as published material. Editing your local draft is fine. Replacing a page after the book is already in circulation is a different act.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A nearby concept often helps people understand the boundary. If you&#8217;re still sorting out how remote updates flow into your local repository, this comparison of <a href=\"https:\/\/deepdocs.dev\/push-vs-fetch\/\">push vs fetch in Git workflows<\/a> gives useful context.<\/p>\n\n\n\n<h3 id=\"the-safer-mental-model\" class=\"wp-block-heading\">The safer mental model<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use amend freely when all of these are true:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Situation<\/th><th>Safe to amend<\/th><\/tr><tr><td>Personal local branch<\/td><td>Yes<\/td><\/tr><tr><td>Commit not pushed anywhere others use<\/td><td>Yes<\/td><\/tr><tr><td>Shared branch already pulled by teammates<\/td><td>No<\/td><\/tr><tr><td>Protected branch like <code>main<\/code><\/td><td>No<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Shared history should be boring. Predictable history is a team feature.<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">There are edge cases where rewriting a remote branch is acceptable, but that requires explicit ownership and coordination. If you have to ask whether the branch is public, treat it as public.<\/p>\n\n\n\n<h2 id=\"how-to-push-amended-commits-and-recover-from-mistakes\" class=\"wp-block-heading\">How to Push Amended Commits and Recover from Mistakes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/cdnimg.co\/c5154994-a2fe-43c0-a286-28e433de4fd1\/a68350d5-7142-4e18-8dfb-361cac2b0c71\/image.jpg?ssl=1\" alt=\"How to Push Amended Commits and Recover from Mistakes\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sometimes you do need to push an amended commit. The usual case is a personal feature branch that only you are using. In that situation, the primary concern isn&#8217;t whether rewriting is possible. It is. The concern is whether you&#8217;ll overwrite something unexpectedly.<\/p>\n\n\n\n<h3 id=\"push-rewritten-history-carefully\" class=\"wp-block-heading\">Push rewritten history carefully<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If the branch tip changed because of amend, a normal push is rejected. That&#8217;s expected. The remote sees a different history.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Prefer this:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> push <span class=\"tok-propertyName\">--force-with-lease<\/span><\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Avoid reaching for plain <code>--force<\/code> by habit. <code>--force-with-lease<\/code> adds a safety check so you&#8217;re less likely to clobber remote work you haven&#8217;t accounted for.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want a practical reference for the mechanics of publishing branch updates, this walkthrough on <a href=\"https:\/\/deepdocs.dev\/how-to-push-code-to-github\/\">how to push code to GitHub<\/a> covers the standard path before you add force semantics.<\/p>\n\n\n\n<h3 id=\"recover-after-a-bad-amend\" class=\"wp-block-heading\">Recover after a bad amend<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The recovery path is the part many tutorials skip, and it&#8217;s the part people remember the day they need it. A reliable rollback starts with reflog.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Core guidance from <a href=\"https:\/\/coreui.io\/answers\/how-to-undo-git-commit-amend\/\">CoreUI&#8217;s explanation of undoing an amended commit<\/a> is to use <code>git reflog<\/code> to find the pre-amend state and then <code>git reset<\/code> to restore it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Start by locating the old tip:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> reflog<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ll see recent HEAD movements, including the amend. Then choose the restore style that matches your intent.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> reset <span class=\"tok-propertyName\">--soft<\/span> HEAD@{1}<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Use <code>--soft<\/code> when you want to move the branch pointer back but keep your changes staged.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> reset <span class=\"tok-propertyName\">--mixed<\/span> HEAD@{1}<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Use <code>--mixed<\/code> when you want the changes kept in your working tree but unstaged.<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> reset <span class=\"tok-propertyName\">--hard<\/span> HEAD@{1}<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Use <code>--hard<\/code> only when you intend to discard working changes.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">When you&#8217;re experimenting locally, reflog is often the difference between panic and a routine cleanup.<\/p>\n<\/blockquote>\n\n\n\n<h3 id=\"a-simple-recovery-checklist\" class=\"wp-block-heading\">A simple recovery checklist<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Stop typing commands fast.<\/strong> Don&#8217;t stack more rewrites on top of the mistake.<\/li>\n\n\n\n<li><strong>Inspect reflog.<\/strong> Identify the pre-amend entry.<\/li>\n\n\n\n<li><strong>Choose reset mode deliberately.<\/strong> Preserve staged work, preserve unstaged work, or discard it.<\/li>\n\n\n\n<li><strong>Verify with <code>git status<\/code> and <code>git log<\/code>.<\/strong> Make sure the branch state matches your intent.<\/li>\n<\/ol>\n\n\n\n<h2 id=\"when-to-use-interactive-rebase-instead\" class=\"wp-block-heading\">When to Use Interactive Rebase Instead<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>git commit --amend<\/code> has a strict boundary. It is for the latest commit. Once the mistake lives deeper in the branch, you need a different tool.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The same Git rewriting guidance that defines amend as the common fix for the most recent commit also points to <strong>interactive rebase<\/strong> for older commits, not amend. That distinction matters because trying to \u201creach back\u201d with amend isn&#8217;t a thing. You have to rewrite the sequence.<\/p>\n\n\n\n<h3 id=\"a-practical-comparison\" class=\"wp-block-heading\">A practical comparison<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use <strong>amend<\/strong> when:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>the newest commit message is wrong<\/li>\n\n\n\n<li>the newest commit is missing a file<\/li>\n\n\n\n<li>the newest commit needs a tiny correction<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Use <strong>interactive rebase<\/strong> when:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>commit three back needs a better message<\/li>\n\n\n\n<li>two commits should be squashed together<\/li>\n\n\n\n<li>an older commit should be edited before review<\/li>\n<\/ul>\n\n\n\n<h3 id=\"example-of-the-cutoff\" class=\"wp-block-heading\">Example of the cutoff<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Say your branch history looks like this:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\">A <span class=\"tok-propertyName\">-<\/span> B <span class=\"tok-propertyName\">-<\/span> C <span class=\"tok-propertyName\">-<\/span> D (HEAD)<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">If <code>D<\/code> is wrong, amend is perfect.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If <code>B<\/code> is wrong, use interactive rebase:<\/p>\n\n\n<div class=\"wp-block-code\">\n\t<div class=\"cm-editor\">\n\t\t<div class=\"cm-scroller\">\n\t\t\t\n<pre>\n<code class=\"language-shell\"><div class=\"cm-line\"><span class=\"tok-variableName\">git<\/span> rebase <span class=\"tok-propertyName\">-i<\/span> HEAD~3<\/div><div class=\"cm-line\"><\/div><\/code><\/pre>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Then mark <code>B<\/code> for <code>reword<\/code> or <code>edit<\/code>, depending on whether you need to change only the message or the snapshot itself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s the mature way to think about it. Amend is a scalpel for the tip of the branch. Interactive rebase is branch surgery for anything behind it.<\/p>\n\n\n\n<h2 id=\"amending-commits-a-tool-for-discipline\" class=\"wp-block-heading\">Amending Commits A Tool for Discipline<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Clean history doesn&#8217;t happen by accident. Engineers create it one decision at a time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use Git commit amend for the last local commit when the change belongs there. Use interactive rebase when the problem sits further back. Leave public history alone unless you fully own the branch and know the consequences. That discipline applies beyond commits too. Strong teams keep code and documentation aligned with the same care.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If your team wants that same hygiene for docs, <a href=\"https:\/\/deepdocs.dev\">DeepDocs<\/a> is worth a look. It&#8217;s a GitHub-native AI app that keeps documentation in sync with code changes automatically, which is useful when fast-moving branches make READMEs, guides, and API docs drift out of date.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You&#8217;ve done it before. You make a commit, hit enter, and then notice the commit message has a typo, a file is missing, or a tiny fix should have been included with the change you just recorded. That&#8217;s the moment git commit &#8211;amend earns its place in a professional workflow. Used well, it keeps your&#8230;<\/p>\n","protected":false},"author":259061979,"featured_media":3616,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"{title}\n\n{excerpt}\n\n{url}","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[1390],"tags":[],"class_list":["post-3615","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Git Commit Amend: Rewrite Git History Safely | DeepDocs<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/deepdocs.dev\/git-commit-amend\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git Commit Amend: Rewrite Git History Safely | DeepDocs\" \/>\n<meta property=\"og:description\" content=\"You&#8217;ve done it before. You make a commit, hit enter, and then notice the commit message has a typo, a file is missing, or a tiny fix should have been included with the change you just recorded. That&#8217;s the moment git commit --amend earns its place in a professional workflow. Used well, it keeps your...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/deepdocs.dev\/git-commit-amend\/\" \/>\n<meta property=\"og:site_name\" content=\"DeepDocs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/profile.php?id=61560455754198\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-06T08:41:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-28T17:07:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/image-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1672\" \/>\n\t<meta property=\"og:image:height\" content=\"941\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Neel Das\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Nilzkool\" \/>\n<meta name=\"twitter:site\" content=\"@Nilzkool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Neel Das\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/\"},\"author\":{\"name\":\"Neel Das\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#\\\/schema\\\/person\\\/cf2ace6ae4dae8b34ab48a3e833ceede\"},\"headline\":\"Git Commit Amend: Rewrite Git History Safely\",\"datePublished\":\"2026-06-06T08:41:21+00:00\",\"dateModified\":\"2026-06-28T17:07:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/\"},\"wordCount\":1785,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/image-1.jpg?fit=1672%2C941&ssl=1\",\"articleSection\":[\"Docs\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/\",\"url\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/\",\"name\":\"Git Commit Amend: Rewrite Git History Safely | DeepDocs\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/image-1.jpg?fit=1672%2C941&ssl=1\",\"datePublished\":\"2026-06-06T08:41:21+00:00\",\"dateModified\":\"2026-06-28T17:07:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/image-1.jpg?fit=1672%2C941&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/image-1.jpg?fit=1672%2C941&ssl=1\",\"width\":1672,\"height\":941},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/git-commit-amend\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/deepdocs.dev\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Git Commit Amend: Rewrite Git History Safely\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#website\",\"url\":\"https:\\\/\\\/deepdocs.dev\\\/\",\"name\":\"DeepDocs\",\"description\":\"Fix Your Outdated GitHub Docs on Autopilot\",\"publisher\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/deepdocs.dev\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#organization\",\"name\":\"DeepDocs\",\"url\":\"https:\\\/\\\/deepdocs.dev\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/6.jpg?fit=408%2C400&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepdocs.dev\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/6.jpg?fit=408%2C400&ssl=1\",\"width\":408,\"height\":400,\"caption\":\"DeepDocs\"},\"image\":{\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/profile.php?id=61560455754198\",\"https:\\\/\\\/x.com\\\/Nilzkool\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/deepdocs-dev\",\"https:\\\/\\\/www.youtube.com\\\/@DrNeelDas\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/deepdocs.dev\\\/#\\\/schema\\\/person\\\/cf2ace6ae4dae8b34ab48a3e833ceede\",\"name\":\"Neel Das\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g\",\"caption\":\"Neel Das\"},\"sameAs\":[\"http:\\\/\\\/neeldasf2ac55feaf.wordpress.com\"],\"url\":\"https:\\\/\\\/deepdocs.dev\\\/author\\\/neeldasf2ac55feaf\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Git Commit Amend: Rewrite Git History Safely | DeepDocs","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/deepdocs.dev\/git-commit-amend\/","og_locale":"en_GB","og_type":"article","og_title":"Git Commit Amend: Rewrite Git History Safely | DeepDocs","og_description":"You&#8217;ve done it before. You make a commit, hit enter, and then notice the commit message has a typo, a file is missing, or a tiny fix should have been included with the change you just recorded. That&#8217;s the moment git commit --amend earns its place in a professional workflow. Used well, it keeps your...","og_url":"https:\/\/deepdocs.dev\/git-commit-amend\/","og_site_name":"DeepDocs","article_publisher":"https:\/\/www.facebook.com\/profile.php?id=61560455754198","article_published_time":"2026-06-06T08:41:21+00:00","article_modified_time":"2026-06-28T17:07:05+00:00","og_image":[{"width":1672,"height":941,"url":"https:\/\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/image-1.jpg","type":"image\/jpeg"}],"author":"Neel Das","twitter_card":"summary_large_image","twitter_creator":"@Nilzkool","twitter_site":"@Nilzkool","twitter_misc":{"Written by":"Neel Das","Estimated reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/deepdocs.dev\/git-commit-amend\/#article","isPartOf":{"@id":"https:\/\/deepdocs.dev\/git-commit-amend\/"},"author":{"name":"Neel Das","@id":"https:\/\/deepdocs.dev\/#\/schema\/person\/cf2ace6ae4dae8b34ab48a3e833ceede"},"headline":"Git Commit Amend: Rewrite Git History Safely","datePublished":"2026-06-06T08:41:21+00:00","dateModified":"2026-06-28T17:07:05+00:00","mainEntityOfPage":{"@id":"https:\/\/deepdocs.dev\/git-commit-amend\/"},"wordCount":1785,"commentCount":0,"publisher":{"@id":"https:\/\/deepdocs.dev\/#organization"},"image":{"@id":"https:\/\/deepdocs.dev\/git-commit-amend\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/image-1.jpg?fit=1672%2C941&ssl=1","articleSection":["Docs"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/deepdocs.dev\/git-commit-amend\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/deepdocs.dev\/git-commit-amend\/","url":"https:\/\/deepdocs.dev\/git-commit-amend\/","name":"Git Commit Amend: Rewrite Git History Safely | DeepDocs","isPartOf":{"@id":"https:\/\/deepdocs.dev\/#website"},"primaryImageOfPage":{"@id":"https:\/\/deepdocs.dev\/git-commit-amend\/#primaryimage"},"image":{"@id":"https:\/\/deepdocs.dev\/git-commit-amend\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/image-1.jpg?fit=1672%2C941&ssl=1","datePublished":"2026-06-06T08:41:21+00:00","dateModified":"2026-06-28T17:07:05+00:00","breadcrumb":{"@id":"https:\/\/deepdocs.dev\/git-commit-amend\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/deepdocs.dev\/git-commit-amend\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/deepdocs.dev\/git-commit-amend\/#primaryimage","url":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/image-1.jpg?fit=1672%2C941&ssl=1","contentUrl":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/image-1.jpg?fit=1672%2C941&ssl=1","width":1672,"height":941},{"@type":"BreadcrumbList","@id":"https:\/\/deepdocs.dev\/git-commit-amend\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/deepdocs.dev\/"},{"@type":"ListItem","position":2,"name":"Git Commit Amend: Rewrite Git History Safely"}]},{"@type":"WebSite","@id":"https:\/\/deepdocs.dev\/#website","url":"https:\/\/deepdocs.dev\/","name":"DeepDocs","description":"Fix Your Outdated GitHub Docs on Autopilot","publisher":{"@id":"https:\/\/deepdocs.dev\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/deepdocs.dev\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/deepdocs.dev\/#organization","name":"DeepDocs","url":"https:\/\/deepdocs.dev\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/deepdocs.dev\/#\/schema\/logo\/image\/","url":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/06\/6.jpg?fit=408%2C400&ssl=1","contentUrl":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/06\/6.jpg?fit=408%2C400&ssl=1","width":408,"height":400,"caption":"DeepDocs"},"image":{"@id":"https:\/\/deepdocs.dev\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/profile.php?id=61560455754198","https:\/\/x.com\/Nilzkool","https:\/\/www.linkedin.com\/company\/deepdocs-dev","https:\/\/www.youtube.com\/@DrNeelDas"]},{"@type":"Person","@id":"https:\/\/deepdocs.dev\/#\/schema\/person\/cf2ace6ae4dae8b34ab48a3e833ceede","name":"Neel Das","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/227924e7431a87895450dcd654b650e5011891dcba027fd9c782941985cbbb2d?s=96&d=identicon&r=g","caption":"Neel Das"},"sameAs":["http:\/\/neeldasf2ac55feaf.wordpress.com"],"url":"https:\/\/deepdocs.dev\/author\/neeldasf2ac55feaf\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/image-1.jpg?fit=1672%2C941&ssl=1","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgAtwt-Wj","jetpack-related-posts":[{"id":1982,"url":"https:\/\/deepdocs.dev\/how-to-commit-to-github\/","url_meta":{"origin":3615,"position":0},"title":"How to Commit to GitHub: A Developer&#8217;s Guide","author":"Emmanuel Mumba","date":"5 January 2026","format":false,"excerpt":"TL;DR: How to Commit to GitHub For Power & Control: Use the Command-Line Interface (CLI) with git add, git commit -m \"message\", and git push. This is the most direct and scriptable method. For Quick Edits: Use the GitHub Web UI. Navigate to a file, click the pencil icon to\u2026","rel":"","context":"In &quot;Docs&quot;","block_context":{"text":"Docs","link":"https:\/\/deepdocs.dev\/category\/docs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/how-to-commit-to-github-developer-guide-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/how-to-commit-to-github-developer-guide-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/how-to-commit-to-github-developer-guide-1.jpg?fit=1200%2C673&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/how-to-commit-to-github-developer-guide-1.jpg?fit=1200%2C673&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/how-to-commit-to-github-developer-guide-1.jpg?fit=1200%2C673&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3413,"url":"https:\/\/deepdocs.dev\/git-remove-file\/","url_meta":{"origin":3615,"position":1},"title":"Master git remove file: Safe Deletion Guide","author":"Neel Das","date":"14 May 2026","format":false,"excerpt":"You remove a file from Git, commit, push, and move on. Then someone checks out an older commit and the file is still there. Or worse, the file contained credentials, a private key, or a giant binary that keeps bloating clones. That\u2019s why git remove file isn\u2019t one command. It\u2019s\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/git-remove-file-git-guide-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/git-remove-file-git-guide-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/git-remove-file-git-guide-1.jpg?fit=1200%2C673&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/git-remove-file-git-guide-1.jpg?fit=1200%2C673&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2026\/05\/git-remove-file-git-guide-1.jpg?fit=1200%2C673&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2163,"url":"https:\/\/deepdocs.dev\/git-reset-hard-origin\/","url_meta":{"origin":3615,"position":2},"title":"A Developer&#8217;s Guide to Git Reset Hard Origin","author":"Neel Das","date":"10 February 2026","format":false,"excerpt":"TL;DR: How to Safely Use git reset --hard origin\/<branch> What it does: Forces your local branch to perfectly match the remote branch, destroying all local commits and uncommitted changes. When to use it: Ideal for abandoning failed local experiments or fixing a corrupted branch when you're 100% sure your local\u2026","rel":"","context":"In &quot;Docs&quot;","block_context":{"text":"Docs","link":"https:\/\/deepdocs.dev\/category\/docs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/git-reset-hard-origin-developers-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/git-reset-hard-origin-developers-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/git-reset-hard-origin-developers-1.jpg?fit=1200%2C673&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/git-reset-hard-origin-developers-1.jpg?fit=1200%2C673&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/git-reset-hard-origin-developers-1.jpg?fit=1200%2C673&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1377,"url":"https:\/\/deepdocs.dev\/how-to-push-code-to-github\/","url_meta":{"origin":3615,"position":3},"title":"How to Push Code to GitHub: A Practical Guide","author":"Emmanuel Mumba","date":"19 October 2025","format":false,"excerpt":"Pushing code to GitHub is a fundamental skill for any developer. At its core, it's a simple, five-command process: init, add, commit, remote, and push. Once you master this workflow, you can turn local projects into shareable, version-controlled repositories, paving the way for collaboration and deployment. TL;DR: Pushing Code to\u2026","rel":"","context":"In &quot;Docs&quot;","block_context":{"text":"Docs","link":"https:\/\/deepdocs.dev\/category\/docs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/10\/Blue-Gradient-Modern-Sport-Presentation-1-4.jpg?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/10\/Blue-Gradient-Modern-Sport-Presentation-1-4.jpg?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/10\/Blue-Gradient-Modern-Sport-Presentation-1-4.jpg?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/10\/Blue-Gradient-Modern-Sport-Presentation-1-4.jpg?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/10\/Blue-Gradient-Modern-Sport-Presentation-1-4.jpg?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2047,"url":"https:\/\/deepdocs.dev\/get-started-with-git\/","url_meta":{"origin":3615,"position":4},"title":"A Practical Guide to Get Started With Git","author":"Neel Das","date":"11 January 2026","format":false,"excerpt":"TL;DR: Your First Steps with Git Install & Configure: First, install Git from the official website and introduce yourself with git config --global user.name \"Your Name\" and git config --global user.email \"youremail@example.com\". Create or Clone: Start a new project with git init in your project folder, or copy an existing\u2026","rel":"","context":"In &quot;Docs&quot;","block_context":{"text":"Docs","link":"https:\/\/deepdocs.dev\/category\/docs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/get-started-with-git-git-guide-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/get-started-with-git-git-guide-1.jpg?fit=1200%2C673&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/get-started-with-git-git-guide-1.jpg?fit=1200%2C673&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/get-started-with-git-git-guide-1.jpg?fit=1200%2C673&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/12\/get-started-with-git-git-guide-1.jpg?fit=1200%2C673&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1386,"url":"https:\/\/deepdocs.dev\/github-source-control\/","url_meta":{"origin":3615,"position":5},"title":"A Developer&#8217;s Guide to GitHub Source Control","author":"Emmanuel Mumba","date":"1 November 2025","format":false,"excerpt":"TL;DR: Your Guide to GitHub Source Control Git vs. GitHub: Git is the local tool that tracks changes on your machine. GitHub is the cloud platform that hosts your projects, enabling team collaboration. Core Git Workflow: The fundamental cycle is git add (staging changes) and git commit (saving a snapshot\u2026","rel":"","context":"In &quot;Docs&quot;","block_context":{"text":"Docs","link":"https:\/\/deepdocs.dev\/category\/docs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/10\/Blue-Gradient-Modern-Sport-Presentation-1-6.jpg?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/10\/Blue-Gradient-Modern-Sport-Presentation-1-6.jpg?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/10\/Blue-Gradient-Modern-Sport-Presentation-1-6.jpg?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/10\/Blue-Gradient-Modern-Sport-Presentation-1-6.jpg?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepdocs.dev\/wp-content\/uploads\/2025\/10\/Blue-Gradient-Modern-Sport-Presentation-1-6.jpg?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/posts\/3615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/users\/259061979"}],"replies":[{"embeddable":true,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/comments?post=3615"}],"version-history":[{"count":2,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/posts\/3615\/revisions"}],"predecessor-version":[{"id":3842,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/posts\/3615\/revisions\/3842"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/media\/3616"}],"wp:attachment":[{"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/media?parent=3615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/categories?post=3615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deepdocs.dev\/wp-json\/wp\/v2\/tags?post=3615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}