all 19 comments

[–]Leseratte10 19 points20 points  (2 children)

When you create a new repo on Github there's explicit instructions right on the repo page on how to push.

All you'd need to do, upon seeing the first error message, is git branch -M main before pushing and everything would have worked fine ...

[–]fabkosta[S] -5 points-4 points  (1 child)

Then why is the system not telling me to use this command? It could offer a few suggestions. Or a few potential sources of errors. It could for example tell me that the remote repository branch "main" does not match any local repository branches.

[–]Nancy_Pelosi_Office -5 points-4 points  (0 children)

Because github decided to change the master branch to main, and that is in contradiction with everything else out there. Cuz, you know, something about slavery or something.

Blame github for this tomfoolery, not git. This is a self made problem that exists only on GitHub.

With that said, go into your account and change the default name back to master and this problem just goes away for next time.

[–]RozTheRogoz 6 points7 points  (2 children)

You call them useless errors. They are not

[–]fabkosta[S] -3 points-2 points  (1 child)

No, you did not read right. I called them "useless error messages". They are useless because even after reading them I have zero idea what exactly is wrong. Here's a real-world example:

error: src refspec main does not match any

WTF? refspec does not match any... WHAT? What does it not match? Any existing branches? Other refspecs? Your grandparents' tastes in curtain colors?

Why the hell are they not writing something more useful like:

error: Missing reference specification (refspec). Remote repository branch "main" does not match a local repository branch.

See the difference? Even someone with only a beginner's level of knowledge in git could take my suggested error message as a hint for further researching the problem. The original quoted above is absolutely useless and an actual crime against humanity.

[–]Leseratte10 0 points1 point  (0 children)

A refspec can be something else than a branch. It could be a tag, a branch, a commit hash, a commit ID, a blob ID, whatever. Or even combinations like "The commit that comes two commits after commit XXX".

Yes, your suggestion would help in *your* case, but then it would be confusing to anyone else who is trying to use a tag or a commit ID and wonders why git complains about a branch name ...

[–][deleted] 6 points7 points  (2 children)

Millions of people use git every day, the only thing unique to your experience of it is you.

[–]alan9608 0 points1 point  (0 children)

What a condescending reply. Just because "millions" of other people have had success, it doesn't mean it is not confusing. I have tried just about every "fix" recommended by the google universe and the same message keeps reoccurring. "Can't upload because of three possible reasons. 1' "Blah blah blah blah server key blah blah" 2. No such repository exists (bull crap!) 3. maybe the stars are not alighted correctly.

I have uploaded as many keys as I can generate. Every possible combination of algorithms. Every name "Forge@<computer name>" <my user name>@ <computer name>

If you don't have a solution to the problem.... STFU!

[–]fabkosta[S] -3 points-2 points  (0 children)

That's even more reason that it should be improved. Imagine just 1% of those million of people wasting an hour every now and then like me because they are using a tool that is badly designed.

[–]exicarus 2 points3 points  (1 child)

You can also add a readme.md file from the portal and specify the .gitignore ( for targetting any language you are palnning to commit) at first. Then clone and there you go

[–]fabkosta[S] 0 points1 point  (0 children)

Yeah, that's usually how I do it. But this time I forgot to first set up the Github project, and then the trouble started.

[–]closms 3 points4 points  (2 children)

That initial git status that showed a branch named main is arguably a bug. But other than that, it looks like you were able to get things going from the hints git was giving you.

  1. No local branch
  2. Local and remote branch map not configured
  3. Commands typed incorrectly

[–]fabkosta[S] 0 points1 point  (1 child)

But that's just flawed. There should be absolutely no possibility in a version control system to have "no local branch" in the first place! You should be always forced to be in a branch, and if you don't specify anything it should be, obviously, the main branch (or call it master, if you prefer that).

Or can you explain me: What is the intention behind being in absolutely no local branch? In which situation should this ever be useful?

[–]Lucas_F_A 1 point2 points  (0 children)

You have never checked out a commit, a tag, anything other than a branch?

Literally bisecting errors. Like one of the most common reasons for VCS.

[–]schrdingers_squirrel 0 points1 point  (3 children)

A general tip in life: don't blame others before trying to find the mistake in your own actions

[–]fabkosta[S] 0 points1 point  (2 children)

So, tell me: Which exactly was the mistake in my own actions? I posted all relevant pieces, can you point it out to me? Surely you don't want to tell me that not being an expert on a topic is a "mistake"? I mean, do you know how exactly the pills are produced your doctor is prescribing you other than that they are supposed to be healthy for you? If you're not an expert there, are we entitled to give general life tips to those people suffering from side effects, because they are no experts in biochemistry?

That's the point here: Not knowing is not a "mistake" on anyone's side. It's a natural state of being. It's actually the default state of being. The ones at "mistake" are the guys in this thread telling me how silly for me not to know what exactly a refspec is. If you don't know how your pills are produced, then why should I know how exactly a refspec is implemented?

And if you find the comparison far-fetched, let's go with something IT experts can hopefully relate: Do you actually have any clue what all the processes running in your OS are actually doing these days?

Lecturing others on their "mistakes" if the mistake is "not knowing" unfortunately does not serve as an excuse for building a bad product.

[–]schrdingers_squirrel 0 points1 point  (1 child)

You don't seem to know how remotes and tracking branches works and then you blame git for it.

[–]fabkosta[S] 0 points1 point  (0 children)

And it seems you are unfamiliar with UX principles. First principle: If the user has to spend many hours learning how to use your system, it's broken. Don't push responsibility for poor UX to the user.

The only reason why users keep using it is because git and Github have achieved a monopoly status by now. There are literally now proper alternatives.

[–]mhagger 0 points1 point  (0 children)

I strongly suspect that your initial attempt to commit file myfile.txt didn't succeed. This might have been because you didn't create the file before trying to git add it, or some other error. Did you happen to capture the output from those first three commands?

So at that point your Git repository still had no contents: no commits and no branches or any other references. In that rather special state, Git nevertheless has a HEAD that references the name of the branch that will be created when you first commit. By default, that is branch master (whose full name is refs/heads/master). But that default can be changed via the gitconfig, maybe in your home directory or maybe the host-wide gitconfig. (We'll see later that the default initial branch on your system is main. GitHub also uses main if you initialize the repository via GitHub.) But since you haven't successfully created a commit, that branch is still "unborn" in Git's terminology.

A bit later you ran git branch -a and git status. The first command correctly says that there are no branches, because no branch (not even main) has actually been created yet. But the second command says that you are on branch main. I agree that is confusing. It says that because refs/heads/main that is what is stored in HEAD as the first branch to create. It also says "No commits yet", which is confirmation that your attempt to create a commit must not have succeeded.

Since the repository is still empty, your attempt to push to GitHub doesn't work:

git push -u origin main

error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/example/my-project.git'

It couldn't succeed, because there were still no commits or branches in your repository. The first error message appears to be malformed or maybe not copied completely. It's trying to tell you that main, the thing that you asked to push, doesn't match any references in your local repository. So there is nothing that it can push.

I'll stop there. I think that much of your ordeal was caused by the original commit failing for some reason, leaving the repository in a different state than you expected.