gitui-org / gitui-org/gitui

Branching from a specific commit

Abierto
#2,292 0 comentarios 0 reacciones 0 asignados Ver en GitHub
feature-request
Lenguaje dominante
Rust
Estrellas
22.5k
Forks
773
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

## 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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en la pantalla Branches [b] y compara sus acciones de branch existentes con la opción Create from propuesta. La tarea estará terminada cuando un usuario pueda introducir un hash de commit o explorar y seleccionar entradas de git reflog para crear un branch de recuperación mediante un proceso fácil de usar y seguro.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
git, rust
Área
cli, devtools
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.