Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty repo cloning bug #232

Open
Abhijit2505 opened this issue Oct 8, 2020 · 6 comments
Open

Empty repo cloning bug #232

Abhijit2505 opened this issue Oct 8, 2020 · 6 comments

Comments

@Abhijit2505
Copy link

@Abhijit2505 Abhijit2505 commented Oct 8, 2020

What article on docs.github.com is affected?

There is a small bug in cloning an empty repository to the local machine, that has not been included in GitHub documentations.

What is the bug?

Steps to check,

  • Create an empty repository in Github.
  • Clone it into the local system.
  • Add some files to it.
  • Open git bash and type git add . then git commit -m
  • Finally git push origin main

It raises an error because the main is not working in case of cloning an empty repo.
If instead of git push origin main, you try git push origin master, it will work.

The bug is - remove the master word and replace it with main, as the master keyword has been removed officially while creating an empty repo.

Additional information

We may have two solutions,

  • Adding this to the documentation page
  • Solving the bug
@welcome
Copy link

@welcome welcome bot commented Oct 8, 2020

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage label Oct 8, 2020
@github-actions github-actions bot added this to Triage in Docs team reviews Oct 8, 2020
@thinkverse
Copy link

@thinkverse thinkverse commented Oct 8, 2020

Is this perhaps a misunderstanding of how git works? 🤔  When git clones an empty repository there isn't a branch added because there are no files that are tracked.

For instance, when I create a new empty repository on GitHub and clone it. I don't have a local branch, only when I start tracking files does it create the branch. And that branch will be named whatever the default is set to.

I believe the default for git is still master but that can be changed by setting the git init.defaultBranch config key as of git v2.28. And you cannot add files from one branch directly into another. So if your system names the branch master and you try to push origin main. Yeah, it's going to throw an error but, I don't think that would be a bug.

@Abhijit2505
Copy link
Author

@Abhijit2505 Abhijit2505 commented Oct 8, 2020

Is this perhaps a misunderstanding of how git works? 🤔  When git clones an empty repository there isn't a branch added because there are no files that are tracked.

For instance, when I create a new empty repository on GitHub and clone it. I don't have a local branch, only when I start tracking files does it create the branch. And that branch will be named whatever the default is set to.

I believe the default for git is still master but that can be changed by setting the git init.defaultBranch config key as of git v2.28. And you cannot add files from one branch directly into another. So if your system names the branch master and you try to push origin main. Yeah, it's going to throw an error but, I don't think that would be a bug.

Maybe you are correct!
I believe the default is still master.

It is not a misunderstanding of how git works, but it is probably a confusion.

@janiceilene
Copy link
Contributor

@janiceilene janiceilene commented Oct 8, 2020

👋 @Abhijit2505 Is there a particular article you'd like to see updated?

@Abhijit2505
Copy link
Author

@Abhijit2505 Abhijit2505 commented Oct 9, 2020

@janiceilene I would really like this thing to be added somewhere inside the docs as a snippet.

@janiceilene
Copy link
Contributor

@janiceilene janiceilene commented Oct 9, 2020

That's definitely something we can consider! Let us know if you find an existing article that makes sense for this update and we can look into it 💛

@janiceilene janiceilene removed the triage label Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.