简体   繁体   中英

master branch not listed in git branch command

I have been tracking a small project with git. I checkout a branch called 'samad'. I have not committed changes for quite long. When I committed the changes and did git branch, I saw only the current branch I'm working on. Master branch was missing. What might be the cause of it and what can I do possibly to bring it back.

When creating a new (empty) repo, no branch is created before the first commit.

If you ran git checkout -b samad before committing on master , the master branch is not created.

You said you have no remote connected. So, simply create a new branch called master from this branch samad .

$ git checkout -b master
  • How have you created this repo ( git init or other)? If you created by git init then master (default branch) should be created automatically. I think, after git init you did checkout to samad . So, master branch is vanished.

Note: If you don't give any commit on master branch then it has no existence actually.

I assume you have already tried:

$ git fetch

Is cloning the project again an option?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM