The link you provided (Support for password authentication was removed. Please use a personal access token instead) is about using a Personal Access Token; it looks like you've solved any problems you have there.
The error message you quoted, where Git asks you to ... Please tell me who you are
, has nothing to do with setting up a Personal Access Token. When you run git commit
, Git must store several things:
- a full snapshot of all of your files (as seen in Git's index or staging area), and
- the metadata that goes into any given commit.
This second part, this metadata, needs to include your name and email address. On some computers, Git can figure out both of these on its own. On other computers, Git needs you to tell it, explicitly, who you are. Git will believe anything you tell it here—you can lie and claim to be Barack Obama or Genghis Khan if you like—but you have to tell it, often both pieces of information. Until you do, git commit
will stubbornly do nothing at all except produce that particular error message.
Git's own instructions here seem pretty clear: you might run
git config --global user.name "Lynda Belfar"
for instance to set your name here, and a similar git config --global
with user.email
and your email address. Once you do that, you can run git commit
: the metadata that Git will use for each new commit you make from this point onward will include this user name and email address (unless and until you change these settings).
Your post title mentions an error message that is nowhere in your question body:
error: could not lock config file C:/Users/admin/Desktop/%Admin%/.gitconfig: No such file or directory
This suggests that your computer is telling Git that your home directory is C:/Users/admin/Desktop/%Admin%
. That's probably incorrect; I don't know why your computer is saying that. I'm not a Windows user either, but in general, logging in directly as "admin" is a bad idea. If you need administrator privileges you can usually set them on a specific user: create a user account, set up a good password for that (different from the good password for the admin account), and go on from there. (But find proper Windows 7 instructions rather than trusting this.)
Meanwhile, this other error message:
error: src refspec main does not match any
occurs when you do not have a branch named main
. This can happen for several reasons:
You might have some commits, but you put them on a branch named master
. If that's the case, decide for yourself whether you prefer the name main
, or like the name master
, or want some other name entirely. Whatever name you want, if it's not master
, you can rename your existing master
(at any time, now or in the future) using git branch -m
.
The -m
here stands for move, and is a slightly weird mnemonic: you might expect -r
or --rename
to rename a branch. But the Git program is the brainchild of Linus Torvalds, who wrote Linux, where the "rename a file" command is mv
, which is short for "move".1 So the "rename a branch" command in Git is "move", abbreviated -m
.
You might not have any commits at all yet. Given that you've been stymied by the user.name
and user.email
setting, you could have a completely empty repository.
Git itself is a little confusing and weird here. In Git, you are, at almost all times,2 "on" some branch. That means that the given branch name is the current branch. But Git also requires that a branch name hold the raw hash ID of some commit. In a new, totally-empty repository, there are no commits. That means that there cannot be any branch names.
Git resolves this tension—that you must be on a branch, yet there can be no branches—by simply putting you on a branch that does not exist. At least, it doesn't exist yet. When you make your first commit, that causes the branch to spring into being. So you have to make a first commit, after which you now have the branch that you were on all along. It makes sense, in a weird way.
Once you have the branch, you can set its name to anything you like—so make your first commit, then rename your branch to whatever name you prefer.
If you're using GitHub, be aware that they now call the initial branch main
instead of master
, even though Git still uses master
by default. This creates lots of opportunities for confusion. You have three pretty good choices here:
Change your Git branch to match GitHub's preference: rename your master
to main
, once you have a master
branch.3
Change your GitHub repository, after creating it: go to the appropriate web page on GitHub and use the web interface to set the default branch name in your GitHub repository back to master
.
Change both names: rename your master
to whatever you like that's neither master
nor main
, and change your GitHub repository setting too.
You also have the choice to leave this in a big mess, with GitHub recommending that clones use main
even though there is no main
in the repository, or using different branch names in each clone. This is possible because each clone has its own branch names, but it's bad from a human standpoint, because it's confusing.5
1To be fair to Linus, he was simply stealing this odd verb from Unix. CP/M and VMS used "rename" (well, CP/M used REN
) so I am not sure if Unix stole mv
/ move
from GCOS, or if that was Ken and/or Dennis.
2When you are in detached HEAD mode, you are not on any branch at all (which is what "detached HEAD" mode means).
3You can rename a branch that doesn't exist yet, or—in modern-enough Git—set the initial branch name to something other than master
. But it's easiest just to remember that a new repository is a little weird. Create a first commit—I like to use one that contains just a README file, for instance, to say what this repository is for—and then rename the branch once you have cleared out that icky "new repository" scent.4
4It's like that "new car" smell. Some people like it, but it's actually mostly off-gassing of VOCs that are likely carcinogenic.
5Unless, that is, you subscribe to the Monty Python Bruces Sketch philosophy.