0

So, here is a situation. I wrote a lot of code and by the end of the day wanted to commit all that. The branch situation was such:

master

working_branch*

What I did after that was:

git branch 11_11_2018

git add everything

git commit -m "msg"

git push --set-upstream origin/11_11_2018 (sth like that)

git checkout master git branch -d 11_11_2018

Now what happened is that I deleted everything I worked on. I'm somewhat new to GitHub and am really afraid to lose all those precious code lines. The problem here was that I meant to checkout 11_11_2018 but didn't and now I don't completely understand what happened. Please, explain what I actually did and how to revert it if possible?

Community
  • 1
  • 1

1 Answers1

0

Run the following command and you should get back all your code:

git checkout -b 11_11_2018 origin/11_11_2018

What you did was pushed all your code to remote branch, switched to master, deleted local branch.

The above command will switch to your remote branch and fetch all your changes with it

Pankaj Singhal
  • 15,283
  • 9
  • 47
  • 86
  • So, I should be able to see the code the way it should be in my github repository in the 11_11_2018 branch then, right? I'm asking because branch 11_11_2018 on github is equivalent to master and is lacking all the code I wrote. – Nolmegar Whitefury Nov 11 '18 at 18:40
  • Why is it lacking all the code? You mentioned in the question that you ran this command `git push --set-upstream origin/11_11_2018`. If you ran this, the code should be in the remote branch on github – Pankaj Singhal Nov 11 '18 at 19:02