gitui-org / gitui-org/gitui

Branching from a specific commit

Ouverte
#2,292 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
feature-request
Langage dominant
Rust
Étoiles
22.5k
Forks
773
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

## Scenario

Consider I made a mistake when discarding commits.
I completely reset the last 3 commits:

```bash
git reset --hard HEAD~3
```

I went back to the working directory and almost had a heart attack when the `my.head` file was gone.
I used `git log` and the commit that created the file is no longer listed.

This file is very important and cannot be lost.

## How to recover

We know it's still possible to recover.

I consult `git reflog` and find out I discarded more commits than intended.
I reset 3 but it should have been 2. The third one was the one that created `my.head`.

To recover, I note the hash shown by `git reflog` for that third commit. And I create a new branch from it.

```bash
git checkout -b recovery 4f02a1d
```

> [!note]
> Even though `git reset --hard ` completely removes changes, what `git` does is mark these changes for future deletion done automatically by `git gc`.
> This makes the changes invisible to `git log` but still present in `git reflog` for some time.

Now I can merge `recovery` branch into `main` branch and get `my.head` back in my working directory.

```bash
git checkout main
git rebase recovery
```

## `gitui`

I didn't find in `gitui` a feature to consult `reflog` or to create a new `branch` from a commit number. I suggest a feature that achieves both goals.

The characteristics of this feature are:

- Provide comprehensiveness
- Not create unnecessary redundancy for existing options in `gitui`
- Provide user-friendly and secure process.


Just as an introduction on how the feature could be implemented, it could be assigned under the `Branches [b]` screen, as a new option like `Create from []`.
`Create from []` opens a screen with two options:

- Type the original `hash` for the new branch
- Display `reflog` and allow scrolling to locate and select the origin for the new branch.

> [!tip]
> Allowing users to create a copy of a previous data snapshot is reassuring for the user. It can be understood as a `panic button`.
> This reinforces the guarantee of not losing data.

## System

OS: Ubuntu 22.04
`gitui` Version: 0.23.3

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par l’écran Branches [b] et comparez ses actions de branche existantes avec l’option Create from proposée. La tâche est terminée lorsqu’un utilisateur peut saisir un hash de commit ou parcourir et sélectionner des entrées de git reflog afin de créer une branche de récupération au moyen d’un processus convivial et sécurisé.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
git, rust
Domaine
cli, devtools
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.