{"id":16022,"date":"2026-09-23T15:27:44","date_gmt":"2026-09-23T13:27:44","guid":{"rendered":"https:\/\/monodes.com\/predaelli\/?p=16022"},"modified":"2026-09-23T15:27:46","modified_gmt":"2026-09-23T13:27:46","slug":"the-git-recovery-guide-how-to-undo-anything-without-panic","status":"publish","type":"post","link":"https:\/\/monodes.com\/predaelli\/2026\/09\/23\/the-git-recovery-guide-how-to-undo-anything-without-panic\/","title":{"rendered":"The Git Recovery Guide: How to Undo Anything (Without Panic)"},"content":{"rendered":"\n<!--more-->\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<h1 class=\"wp-block-heading\"><a href=\"https:\/\/dev.to\/james_anderson_h\/the-git-recovery-guide-how-to-undo-anything-without-panic-547e\">The Git Recovery Guide: How to Undo Anything (Without Panic)<\/a><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">There&#8217;s a specific feeling every developer knows. You run a git command, hit Enter, and half a second later your stomach drops because you realize what you just did. Three hours of work, gone from <code>git log<\/code>. The wrong branch, obliterated. A rebase that turned your history into soup.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Take a breath, because here&#8217;s the truth that this entire guide rests on:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Git almost never actually deletes your work.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When you &#8220;lose&#8221; a commit, it&#8217;s usually not destroyed \u2014 it&#8217;s just <em>orphaned<\/em>, meaning nothing points to it anymore. The commit is still sitting in git&#8217;s database, and its hash is still recorded in a log of everything you&#8217;ve done. Recovery is almost always possible. You just need to know which command brings it back.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide is organized by <strong>what you just did<\/strong>. Find your situation, copy the fix, breathe. Bookmark it now \u2014 you will need it someday, probably at 2am.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/dev.to\/james_anderson_h\/the-git-recovery-guide-how-to-undo-anything-without-panic-547e#the-one-idea-that-makes-all-of-this-make-sense\"><\/a> The one idea that makes all of this make sense<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before the recipes, thirty seconds of theory that turns this from magic into something you understand.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Git rarely destroys anything. It moves <em>references<\/em> \u2014 the little pointers (branches, HEAD) that say &#8220;the current state is here.&#8221; When you reset, delete a branch, or botch a rebase, you&#8217;re usually just moving a pointer, not deleting commits. The commits stay in git&#8217;s object database until garbage collection eventually clears the unreferenced ones.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And git keeps two safety nets:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>The reflog<\/strong> \u2014 a log of every move your <code>HEAD<\/code> and branches have made. Think of it as git&#8217;s security-camera footage of your own actions. Even &#8220;lost&#8221; commits show up here with their hashes. Run <code>git reflog<\/code> and you can see everywhere you&#8217;ve been.<\/li>\n\n\n\n<li><strong><code>git fsck<\/code><\/strong> \u2014 finds orphaned (&#8220;unreachable&#8221;) objects when even the reflog isn&#8217;t enough.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Nearly every recovery below is really just: <em>find the hash of where you want to be, and point something at it again.<\/em> That&#8217;s it. Now the recipes.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/dev.to\/james_anderson_h\/the-git-recovery-guide-how-to-undo-anything-without-panic-547e#part-1-undoing-uncommitted-changes\"><\/a> Part 1 \u00b7 Undoing uncommitted changes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Discard changes to one file (before staging):<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git restore &lt;file&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Throws away your uncommitted edits to that file, restoring it to the last commit. (This is the modern command; you may have muscle memory for <code>git checkout &lt;file&gt;<\/code>, which still works but <code>restore<\/code> is clearer.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Unstage a file but keep the changes:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git restore --staged &lt;file&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Removes it from staging; your edits stay in the working directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Discard ALL uncommitted changes:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git restore .\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u26a0\ufe0f This is destructive \u2014 it permanently throws away uncommitted work, and since it was never committed, the reflog can&#8217;t save you. Make sure you mean it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Recover a file you deleted but hadn&#8217;t committed:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git restore &lt;file&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As long as the deletion wasn&#8217;t committed, the file comes right back from HEAD.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/dev.to\/james_anderson_h\/the-git-recovery-guide-how-to-undo-anything-without-panic-547e#part-2-fixing-commits\"><\/a> Part 2 \u00b7 Fixing commits<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Fix a typo in your last commit message:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git commit --amend\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You forgot to include a file in the last commit:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git add forgotten-file.js\ngit commit --amend --no-edit\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>--no-edit<\/code> keeps the existing message.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Undo the last commit but KEEP the changes<\/strong> (put them back as uncommitted work):<br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset --soft HEAD~1\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The commit is undone; your changes are safe and staged. This is the gentle, safe undo.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Undo the last commit AND discard the changes:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset --hard HEAD~1\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u26a0\ufe0f <code>--hard<\/code> throws away the changes too. If you didn&#8217;t mean to lose them, don&#8217;t panic \u2014 the reflog can recover this (see Part 3). But run it carefully.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Undo a commit that&#8217;s already pushed \/ shared<\/strong> \u2014 use revert, not reset:<br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git revert &lt;commit-hash&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This creates a <em>new<\/em> commit that reverses the old one. Nothing is rewritten, so it&#8217;s safe on shared branches \u2014 nobody&#8217;s history breaks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The reset vs. revert rule, once and for all:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>reset<\/code><\/strong> rewrites history \u2014 great for <em>local, private<\/em> commits nobody else has.<\/li>\n\n\n\n<li><strong><code>revert<\/code><\/strong> adds a new undo-commit \u2014 the <em>polite<\/em> way to undo <em>shared<\/em> commits without ruining your teammates&#8217; day.<\/li>\n\n\n\n<li>Rule of thumb: if you&#8217;ve pushed it and others might have it, <code>revert<\/code>.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/dev.to\/james_anderson_h\/the-git-recovery-guide-how-to-undo-anything-without-panic-547e#part-3-the-oh-no-recoveries-meet-the-reflog\"><\/a> Part 3 \u00b7 The &#8220;oh no&#8221; recoveries (meet the reflog)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is the heart of the guide. Almost every panic below is fixed the same way: <code>git reflog<\/code>, find the hash, point something at it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You ran <code>git reset --hard<\/code> and lost commits:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reflog\n# find the entry from BEFORE the reset \u2014 e.g. abc1234 HEAD@{1}\ngit reset --hard abc1234\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your commits come right back. The reflog recorded where HEAD was before you reset.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You deleted a branch that had commits on it:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reflog\n# find the last commit that was on the branch, then recreate it:\ngit branch recovered-branch abc1234\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Deleting a branch only removes the <em>label<\/em> \u2014 the commits are still there. This re-attaches a label to them.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You botched a rebase:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reflog\n# look for entries around \"rebase (start)\" \/ \"rebase (finish)\"\n# find the commit from BEFORE the rebase and reset to it:\ngit reset --hard HEAD@{5}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Rebasing rewrites commits, but the originals are still in the reflog.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You made commits in a detached HEAD and switched away<\/strong> (they now have no branch pointing to them):<br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reflog\n# find your commit's hash, then give it a branch before it ages out:\ngit branch rescued abc1234\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>When the reflog isn&#8217;t enough \u2014 the deeper safety net:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git fsck --unreachable | grep commit\n# inspect each candidate to find the one you want:\ngit show &lt;hash&gt;\n# then recover it:\ngit branch recovered &lt;hash&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How to read the reflog<\/strong> (so it&#8217;s not intimidating):<br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reflog --date=relative\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Entries look like <code>HEAD@{2}<\/code> \u2014 that means &#8220;where HEAD was 2 moves ago.&#8221; You can use those references directly, e.g. <code>git reset --hard HEAD@{2}<\/code>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/dev.to\/james_anderson_h\/the-git-recovery-guide-how-to-undo-anything-without-panic-547e#part-4-undoing-merges-and-sharedhistory-scares\"><\/a> Part 4 \u00b7 Undoing merges and shared-history scares<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You merged into the wrong branch, or merged by accident (and haven&#8217;t pushed):<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Git automatically saves where you were <em>right before<\/em> a merge in a reference called <code>ORIG_HEAD<\/code>, which makes this a one-liner:<br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset --hard ORIG_HEAD\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That snaps you back to exactly your pre-merge state. <code>ORIG_HEAD<\/code> is your best friend after any merge.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the merge wasn&#8217;t the very last thing you did, find the pre-merge commit in <code>git reflog<\/code> and reset to it instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You merged into the wrong branch entirely<\/strong> (meant to merge into <code>feature<\/code>, hit <code>main<\/code>):<br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># on the wrong branch (e.g. main):\ngit reset --hard ORIG_HEAD      # undo the accidental merge\ngit switch feature              # go to the branch you meant\ngit merge your-branch           # merge properly this time\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The merge is already pushed \/ shared<\/strong> \u2014 don&#8217;t reset, revert it:<br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git revert -m 1 &lt;merge-commit-hash&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>-m 1<\/code> tells git which parent to keep (the mainline branch, usually parent 1). This undoes the merge with a new commit, safely, without rewriting shared history.<br \/>\u26a0\ufe0f Gotcha worth knowing: after reverting a merge, git considers that branch &#8220;already merged.&#8221; If you later want to genuinely re-merge it, you&#8217;ll have to revert the revert first. Just be aware.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You need to undo a <code>git push<\/code>:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Safe way (shared branches):<\/strong> <code>git revert &lt;hash><\/code> and push the revert.<\/li>\n\n\n\n<li><strong>Rewriting way (only if you&#8217;re sure no one else has pulled):<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>git reset --hard &lt;good-hash&gt;\ngit push --force-with-lease\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u26a0\ufe0f <strong>Always use <code>--force-with-lease<\/code>, never plain <code>--force<\/code>.<\/strong> <code>--force-with-lease<\/code> refuses to overwrite if someone else has pushed in the meantime \u2014 it stops you from silently destroying a teammate&#8217;s work. Plain <code>--force<\/code> is how you cause an incident.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Someone force-pushed over your work:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git reflog\n# find your last good commit before their overwrite:\ngit reset --hard HEAD@{n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your local reflog still has your version, even if the remote was overwritten. (This is one more reason the reflog is a lifesaver.)<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/dev.to\/james_anderson_h\/the-git-recovery-guide-how-to-undo-anything-without-panic-547e#part-5-other-lifesavers\"><\/a> Part 5 \u00b7 Other lifesavers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You dropped a stash you needed:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git fsck --unreachable | grep commit\n# check candidates with git show &lt;hash&gt;, then:\ngit stash apply &lt;hash&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Dropped stashes are orphaned, not gone \u2014 for a while.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You&#8217;re mid-merge \/ mid-rebase \/ mid-cherry-pick and it&#8217;s a mess \u2014 bail out:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git merge --abort\ngit rebase --abort\ngit cherry-pick --abort\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These return you cleanly to the state before you started the operation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You want to peek at an old version of a file without losing your current work:<\/strong><br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git restore --source=&lt;commit-hash&gt; &lt;file&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Or view it without changing anything: <code>git show &lt;commit-hash&gt;:&lt;file&gt;<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You ran <code>git clean<\/code> and deleted untracked files:<\/strong><br \/>Here&#8217;s the one honest hard limit in this guide: <strong><code>git clean<\/code> deletes untracked files for good.<\/strong> They were never in git, so git can&#8217;t bring them back. (Editor local-history or your OS trash are your only hope.) This is <em>the<\/em> command to run carefully \u2014 always preview first with <code>git clean -n<\/code>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/dev.to\/james_anderson_h\/the-git-recovery-guide-how-to-undo-anything-without-panic-547e#before-you-panic-the-survival-rules\"><\/a> Before you panic: the survival rules<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Print these on the inside of your eyelids:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Stop. Don&#8217;t run more commands blindly.<\/strong> Panicked flailing is how people lose the work a <em>second<\/em> time, for good. Read this, then act deliberately.<\/li>\n\n\n\n<li><strong>Recover fast.<\/strong> Reflog entries expire \u2014 roughly 30 days for unreachable commits, 90 for reachable ones \u2014 and <code>git gc<\/code> can prune them earlier. Don&#8217;t sit on it for a week.<\/li>\n\n\n\n<li><strong>The reflog is local and per-clone.<\/strong> It only knows what <em>this<\/em> copy did. It won&#8217;t help in a fresh clone, and you can&#8217;t recover a teammate&#8217;s mistake from your machine.<\/li>\n\n\n\n<li><strong>When in doubt, make a backup branch before trying anything risky:<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\"> <code> git branch backup-before-i-do-something-scary\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Costs nothing, and it&#8217;s a guaranteed anchor to come back to.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/dev.to\/james_anderson_h\/the-git-recovery-guide-how-to-undo-anything-without-panic-547e#the-takeaway\"><\/a> The takeaway<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The scariest thing about git was never the mistakes. It&#8217;s not <em>knowing<\/em> they&#8217;re reversible \u2014 that gap between hitting Enter and remembering the reflog exists, where it feels like you just deleted hours of your life.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But now you know the secret the whole guide is built on: git moves references, it rarely destroys work, and almost everything is recoverable if you act before garbage collection does. A bad reset, a deleted branch, a botched rebase, an accidental merge, even a force-push \u2014 they&#8217;re one <code>git reflog<\/code> away from being fixed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Bookmark this. The next time your stomach drops, you&#8217;ll have the fix in ten seconds instead of ten frantic browser tabs. And you&#8217;ll be the person in the room who calmly says the one word everyone needs to hear:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Reflog.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><em>What&#8217;s the git disaster that taught you the reflog exists? Mine was a <code>git reset --hard<\/code> on the wrong branch \u2014 three hours of work vanished from the log, heart in my throat \u2014 until a senior dev glanced over and said one word that brought it all back. What&#8217;s your story?<\/em><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/monodes.com\/predaelli\/2026\/09\/23\/the-git-recovery-guide-how-to-undo-anything-without-panic\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"link","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"federated","footnotes":"","jetpack_publicize_message":"","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},"jetpack_post_was_ever_published":false},"categories":[72,278],"tags":[],"class_list":["post-16022","post","type-post","status-publish","format-link","hentry","category-documentations","category-tricks","post_format-post-format-link"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6daft-4aq","jetpack-related-posts":[{"id":11688,"url":"https:\/\/monodes.com\/predaelli\/2024\/06\/01\/never-use-git-pull-youtube\/","url_meta":{"origin":16022,"position":0},"title":"Never* use git pull &#8211; YouTube","author":"Paolo Redaelli","date":"2024-06-01","format":"video","excerpt":"https:\/\/www.youtube.com\/watch?v=xN1-2p06Urc Just a quick summary mostly for myself: How to use git pull --rebase to keep your team's commit history clean. Command for creating the 'git pr' alias (so you can copy-paste): git config --global alias.pr \"pull --rebase\" Always try git pull --rebase first. It if works, you're done! If\u2026","rel":"","context":"In &quot;Tricks&quot;","block_context":{"text":"Tricks","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/tricks\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/img.youtube.com\/vi\/xN1-2p06Urc\/0.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":11167,"url":"https:\/\/monodes.com\/predaelli\/2024\/01\/10\/lets-clone-simplemobiletools\/","url_meta":{"origin":16022,"position":1},"title":"Let&#8217;s clone SimpleMobileTools","author":"Paolo Redaelli","date":"2024-01-10","format":false,"excerpt":"Since SimpleMobileTools has been sold by its creator to a company notorious for buying apps from developers and repacking them with ads, putting a \"no-ads\" subscription to remove it for $15 a week, the time is ripe to clone its repositories! Join me, I already did it!: git clone https:\/\/github.com\/SimpleMobileTools\/Simple-App-Launcher\u2026","rel":"","context":"In &quot;Ethics&quot;","block_context":{"text":"Ethics","link":"https:\/\/monodes.com\/predaelli\/category\/ethics\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2024\/01\/may-the-source-be-with-you-0.webp?fit=750%2C1000&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2024\/01\/may-the-source-be-with-you-0.webp?fit=750%2C1000&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2024\/01\/may-the-source-be-with-you-0.webp?fit=750%2C1000&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2024\/01\/may-the-source-be-with-you-0.webp?fit=750%2C1000&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":915,"url":"https:\/\/monodes.com\/predaelli\/2016\/01\/21\/find-and-restore-a-deleted-file-in-a-git-repository\/","url_meta":{"origin":16022,"position":2},"title":"Find and restore a deleted file in a Git repository","author":"Paolo Redaelli","date":"2016-01-21","format":false,"excerpt":"Use git log --diff-filter=D --summary to get all the commits which have deleted files and the files deleted;Use git checkout $commit~1 filename to restore the deleted file. Sorgente: Find and restore a deleted file in a Git repository - Stack Overflow","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":11886,"url":"https:\/\/monodes.com\/predaelli\/2024\/09\/01\/git-copy-a-file-or-directory-from-another-repository-preserving-the-history\/","url_meta":{"origin":16022,"position":3},"title":"Git: Copy a file or directory from another repository preserving the history","author":"Paolo Redaelli","date":"2024-09-01","format":"quote","excerpt":"How to copy a file or directory from another GIT repository while preserving its history? Internet is full of magic formulas each one more complex. Here I\u2019m proposing a much simpler and faster one that is to make a git format-patch for the entire history of the file or subdirectory\u2026","rel":"","context":"In &quot;Tricks&quot;","block_context":{"text":"Tricks","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/tricks\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2449,"url":"https:\/\/monodes.com\/predaelli\/2017\/05\/11\/versionpress-git-for-wordpress-sites\/","url_meta":{"origin":16022,"position":4},"title":"VersionPress \u2013 Git for WordPress sites","author":"Paolo Redaelli","date":"2017-05-11","format":"link","excerpt":"VersionPress WordPress + Git = \u2661","rel":"","context":"In &quot;Senza categoria&quot;","block_context":{"text":"Senza categoria","link":"https:\/\/monodes.com\/predaelli\/category\/senza-categoria\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2081,"url":"https:\/\/monodes.com\/predaelli\/2017\/01\/12\/when-to-make-a-git-commit\/","url_meta":{"origin":16022,"position":5},"title":"When to make a Git Commit","author":"Paolo Redaelli","date":"2017-01-12","format":"link","excerpt":"https:\/\/dev.to\/gonedark\/when-to-make-a-git-commit","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/16022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/comments?post=16022"}],"version-history":[{"count":1,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/16022\/revisions"}],"predecessor-version":[{"id":16023,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/16022\/revisions\/16023"}],"wp:attachment":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/media?parent=16022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/categories?post=16022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/tags?post=16022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}