You screwed your git history? Don’t panic!

you-screwed-your-git-history?-don’t-panic!

Using git is a long journey. I’m still learning things even after a decade of using it daily at work.

You will need time to understand what you do. Unfortunately, the best way to learn is to fail. And you will fail a lot with git, believe my own experience.

It requires understanding the concepts you are using: branch, rebase, merge, push, cherry-pick, stash, squash, fixup, reflog …

You will need time to understand all these. The main issue is that the ones who make the most mistakes are the ones that are starting using git, and they are likely to do the worst mistakes. Yes, unfair.

I consider myself as an advanced git user. Some may say it’s an imposter syndrome, because they think I’m almost an expert, but I consider we can always progress.

I would like to give you guys some references and tools.

Don’t panic, and try to understand what you did

You need to figure what you made, before trying to fix it.

So take the time needed to understand.

Then you need to do a backup

As always, I would recommend you to perform backup before trying anything.

Copy your repository project, including the .git folder somewhere. Think about using mktemp -d.

Then try to solve your issue in this /tmp/ folder, not in your repository. This will avoid screwing everything even more. And you can restart trying fixing if you fail.

How to fix then ?

Here is good reference and resource: https://ohshitgit.com/

It will provide you guidance and what to do to recover.

There is also a tool that can help you. I found it recently.

GitHub logo

Bhupesh-V
/
ugit

🚨️ ugit helps undo git commands. Your damage control git buddy. Undo from 20+ git scenarios.

ugit

ugit logo

Undo your last oopsie 🙈️ in git


build ugit


Docker pulls

total downloads (github + brew)

platform support linux and macos


git undo text guide


Twitter: bhupeshimself

ugit demo: restore file gif

More Video Demos ✨️

Undo git add

undo-git-add.mp4

Undo git branch -D

undo-git-branch-delete.mp4

Undo git merge

undo-git-merge.mp4

Why use ugit?

  • You accidentally ran a git command you wish to ‘undo’.
  • You want to save time by not searching for how to undo …
  • Your focus is on the problems at hand and not on Git (avoid context switching)

What’s in the box?

ugit/git-undo supports undoing the following operations, some are a WIP. If you know of any other operations that can be undone and are not in the list, make sure to raise an issue or make a quick PR 💛️

  • Undo git commit
  • Undo git add
  • Undo git push
  • Undo git branch -D (branch delete)
  • Undo git pull
  • Undo git reset
  • Undo git tag -d (tag delete)
  • Undo git stash apply
  • Undo git

Photo credits: https://www.tumblr.com/dictatortirah

Total
0
Shares
Leave a Reply

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

Previous Post
google-makes-it-official:-content-marketing-is-now-the-#1-ranking-factor

Google Makes It Official: Content Marketing Is Now the #1 Ranking Factor

Next Post
12章13

12章13

Related Posts
在termux中安装和使用google-gemini-cli的完整指南

在Termux中安装和使用Google Gemini CLI的完整指南

什么是Google Gemini CLI? Google Gemini CLI是一个命令行工具,允许开发者直接在终端中与Google的Gemini AI模型交互。它提供了简单高效的方式来测试和集成Gemini的强大AI能力到你的开发工作流中。 Gemini是Google最新推出的大型语言模型,具有强大的自然语言理解和生成能力,可以用于代码生成、问题解答、内容创作等多种场景。 在Termux中安装Gemini CLI Termux是Android设备上的强大终端模拟器,下面我们一步步教你如何在Termux中安装和使用Gemini CLI。 1. 准备工作 首先确保你的Termux是最新版本,并更新软件包: pkg update &&…
Read More