Solve the fatal:remote error:You can't push to git://github.com/username/*.git problem when Git push

question

In the case where everything is normal: git push has the following problems

fatal: remote error: 
  You can't push to git://github.com/你的git用户名/Demo.git
  Use https://github.com/你的git用户名/Demo.git

The results of the investigation are all saying that the problem will occur when the form is used for cloning git clone git://github.com:xx/xxx.git. It should be because this protocol only has read permissions and cannot be written. As a result, push cannot be made.

But what I use is git clone https://github.com/Mingxiangyu/Demo.git, and it has been a normal pull and push operation before. Recently, after hanging up an agent, I can’t push for no reason.

Solution one:

Finally, according to the solution from Baidu, the problem was solved.
Enter the following two commands in the console and try again git push.

git remote rm origin
git remote add origin git@github.com:git用户名/仓库名.git

If the following problems occur

fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

Then execute the following command

 git push --set-upstream origin main

The following prompt appears to prove that the upstream branch is set successfully

Branch 'main' set up to track remote branch 'main' from 'origin'.

After performing this operation, it can be normal git push, git pulland the operation is

Solution two:

8-30 New solution

  1. Enter the project folder directory and find .gitthe folder ( if it is not displayed, please open the view hidden directory option )
    The effect is as shown in the figure
  2. Find configthe file and open it as shown in the figure below:

    If the url starts with http , such as: https://github.com/用户名/仓库名, for example: https://github.com/kobeyk/SpringBoot-ShpTools.git
    then modify it to [email protected]:用户名/仓库名, note that there is an English symbol between github.com and the user name:

Guess you like

Origin blog.csdn.net/qq_43961619/article/details/116595085