'Master branch disappeared from my local code
I have a repo that I cloned a long ago and I use the master that I push to create my branches to then merge with master.
I opened visual studio and now I don't see any branch, not even master and I did not made any changes or delete any branches.
I dont make any changes using bash, just the .net git
Is there a way to get the master branch?
Solution 1:[1]
In my particular case, for some reason I do not know yet, the .git hidden folder became corrupt. As stated in this question, the first answer fatal: Failed to resolve HEAD as a valid ref
Solve the issue. Pretty much clone the repository again somewhere, copy that .git (cloned), remove the original .git (in the original repository) and put the cloned one instead.
Solution 2:[2]
First, fall back to command-line in order to ascertain the situation:
cd /path/to/local/repository
git status
git branch -avv
Then, check which toggle is selected in the "History view
" of your Visual Studio (local branches, remote tracking branches, or tags).
Getting back to the command line allowed the OP Nickso to see the local .git
was no longer coherent, and needed to be restored, as details in Nickso's answer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nickso |
Solution 2 |