Revert a commit that hasn’t been pushed yet, and with multiple comits waiting to get pushed

Asked

Viewed 100 times

0

In one of the commits that I performed I included a folder with several files that total about 5gB, trying to push the same commit occurred an error (fatal: The remote end hung up unexpectedly), and the push did not finish correctly. Unfortunately I didn’t realize that this had happened, and I kept working and doing new commits, whenever I tried to push, the mistake repeated. Now there are several commits that did not receive push, there are 8 in total.

This is the output of the git status command: git status:


$ git status
On branch Optimizando
Your branch is ahead of 'origin/Optimizando' by 8 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   MAIN/DataResources/ExcelTables/Consola_00.xlsx
        modified:   MAIN/FUNCTIONS/Operar_Binary.py
        modified:   MAIN/FUNCTIONS/__pycache__/Operar_Binary.cpython-37.pyc
        modified:   MAIN/OPERATION_00.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitingnore
        ESTADISTICAS/
        MAIN/DataResources/ExcelTables/LOG.xlsx
        MAIN/F5.py
        MAIN/FUNCTIONS/copia.py
        MAIN/__pycache__/indices.cpython-37.pyc
        MAIN/test-2.py

no changes added to commit (use "git add" and/or "git commit -a")


the output of the git Cherry -v command is as follows:


$ git cherry -v
+ d67a194ca3abc6847545488471a37a37bdfac060 Estadistica feu incorporado al servidor
+ 90021137be3752cf043fa9a67a9219121b5d9d95 error pabo
+ 6d65ef35c0568c5c261ce9b26d1fbe7526e02048 fix
+ c718a223615e84e2f2ef9172487bac7a58aeafce funcion gigante subdibidida
+ cd3e1e25a84da83e98e01c06df216fcc5e8f81d2 Conflictos
+ 20dae7b7f65762823cdc9f473e5bbe78d02479c7 Incorporacion Indices sintectico y eliminacion de Estadistica
+ 73d93be70f84c71bb98c8d519f7b742a12686472 Correcion en Menu desplegable de activos
+ a5e7f8d5d25f181f2d1ed39a76d509c272417933 Correcion en la seleccion de activo forex

the commit into which the files causing the error were entered is the id: "d67a194ca3abc68475488471a37a37bdfac060 Estadistica Feu embedded server"

How can I reverse this commit without losing the work that was done after I added the files? An important detail, the folder that contained the files was originally called "Static", in the desperation I tried to rename it to STATICS but this did not solve the problem.

Thanks so much for your help.

1 answer

0

You can make a

git rebase -i d67a194ca^

and will open a screen where you can change the order of the commits, change the description, etc. It is a very powerful command. From what I understand you want to discard the d67a194 commit, then edit the respective line by replacing "pick" with "drop". Or simply remove the line, the commit will be despised.

It is important to remember that this will "rewrite history", that is, the commits that came after d67a194 will be redone as if it had not existed. If this causes some conflict, you may have to resolve it manually.

If you read in English, you can take a look at my text https://epxx.co/artigos/gitfaces.html which describes the use of git rebase -i and conflict editing during interactive rebase.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.