How did that happen ?
I simply wanted to rename two of my git branches, local and remote. For the sake of understanding, let's say I wanted to rename the branch EVOL
to DEV
, and the branch DEL
to DELIVERY
.
To do so, I used the commands decribed here. It's quite simple. Firstly, I did, while in EVOL
git branch -m DEV
git push origin :EVOL DEV
git push origin -u DEV
Using gitk
, I saw the change was effective, and did everything I wanted. So, to rename my second branch, I did the following commands (still in the now-called DEV
branch)
git branch -m DEL DELIVERY
git push origin :DEL DELIVERY
git push origin -u DELIVERY
Here is where I failed. I should have done the last command in the DELIVERY
branch, except I did not change, I was trying to be quick, and I didn't see the instruction on the webpage.
Consequences and problem
The DEV
branch looks just like I wanted: same old EVOL
branch, with a new name. However, the DELIVERY
branch is just wrong, where I believe another branch was, months earlier than where DEL
was. To be honest, I don't remember the use of the branch where DELIVERY
is now, but ideally I would like to revert here as well whatever there was, to keep a clear history. Worse, it looks like I have lost track of my old DEL
branch with its commit. I am unable to find them using gitk --all
.
Since I realized my mistake, I didn't dare to try something, by fear of losing the old DEL
commits. The last command I executed is that infamous git push origin -u DELIVERY
Question
Is it possible to revert that last command git push origin -u DELIVERY
and/or to retrieve my commits that were on the DEL
branch ?