How to add a new project to github?

First, you can refer to the official document.

The following are the troubleshootings when I executed the commands in official document:

Issue 1:

When I executed the command in step 5 according to official document, I got the following error.

git commit -m "example for pthread usage"

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'xiemei@DESKTOP-MTMR4VC.(none)')

so I used the following commands to configure the email and name.

$ git config --global user.email "xxx@qq.com"
$ git config --global user.name "emily"

Issue 2:

When I executed the “git push origin master” command, I got the following error:

$ git push origin master
The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I found there are no id_rsa and id_rsa.pub in ~/.ssh directory.

Thus, change the current working directory to ~/.ssh and run the “ssh-keygen -t rsa” command.

Then, copy the content in id_rsa.pub and paste it to SSH and GPG keys in github website. (Click icon in upper right -> Settings -> SSH and GPG keys)

Issue 3:

After I had resolved the above issue, I met the following issue.

$ git push origin master
To github.com:XmHuster/codes.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:XmHuster/codes.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details

Thus, I run the “git pull origin master” command firstly. But I got the following error.

$ git pull origin master
From github.com:XmHuster/codes
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

Because I have a readMe.md file in remote repository and a example folder in local master. I added the “–allow-unrelated-histories” option to avoid this error.

Now, I run the “git push origin master” command to submit the example folder. It is successful.

Have a good day and Good luck.

Reference: About SSH content in official document.

Share this article to your social media
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments