How to revert git branch with all commits?

52 views Asked by At

I was deleted my barnch form Github Branch Page. What i did before deleted my branch?

  1. Resetup my ubuntu os, git SSH keys, downloaded repo zip file.
  2. Extract the zip file.Then added remote url.
  3. Then push it to main.

After that a checked my repo.Main converted to master because perviously there was a main branch. I then i thoguht main is alrady there so i can delete master.I deleted master branch and then my all 75 commits deleted from history.

My all data avaliable in newly created branch.But want to get back my 30 days commits history

After download Zip file and commit history. `

d235da2047b7ef76bc2145831b8340edb0f3cbcc (HEAD -> master, origin/recovered-branch, origin/master, origin/demo) HEAD@{8}: Branch: renamed refs/heads/master to refs/heads/main
d235da2047b7ef76bc2145831b8340edb0f3cbcc (HEAD -> master, origin/recovered-branch, origin/master, origin/demo) HEAD@{10}: commit (initial): added new test case
(END)

1 day ago befor doing all this thing.

commit 361022ebfb34de02f3f8638001572457e14a2109
| Author: techtobit <[email protected]>
| Date:   Fri Sep 1 16:34:26 2023 +0600
| 
|     removed space
| 
* commit 83624239bebdaf8d1fac8c8df689c15484db7f70
| Author: techtobit <[email protected]>
| Date:   Thu Aug 31 22:16:53 2023 +0600
| 
|     FloyWarshall
| 
* commit 53dc3d9be04f2c4a79ef9bfcd5af69906a9513af
| Author: techtobit <[email protected]>
| Date:   Wed Aug 30 22:41:05 2023 +0600
| 
|     bellman ford
| 
* commit 33f53083596808c8fc5c43b56ac07aaf386ceacd
| Author: techtobit <[email protected]>
| Date:   Mon Aug 28 04:42:56 2023 +0600
:

`

Could anyone please help me? Thank YOu.

How can I get back my 30-day commits history with the deleted branch?

1

There are 1 answers

0
hlovdal On

1 day ago befor doing all this thing.

commit 361022ebfb34de02f3f8638001572457e14a2109

This is a good starting point. You can create a branch for this commit

git branch one_day_ago 361022eb

and I guess that would bring back most of the 75 commits.

Git does not immediately purge from disk commits that are no longer referenced by any branch/tag, they are garbage collected after 4 weeks or something like that.

There is also git reflog mechanism that keeps track of what you have worked with, and it might contain newer commits than 361022eb as well.

For a convenient way of inspecting the reflog you can launch gitk with the --reflog argument.