Username for 'https://github.com': 输入的是github上的邮箱账号, 而不是github中设置的username, 这是个巨坑!!!
Password for 'https://你的github邮箱@github.com': 输入github的登录密码,点击enter键即可.
~/github/ZYCycleViewSwift/ master: git push --set-upstream origin master
Username for 'https://github.com': 1512450002@qq.com
Password for 'https://1512450002@qq.com@github.com':
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (14/14), 1.88 KiB | 1.88 MiB/s, done.
Total 14 (delta 9), reused 0 (delta 0)
remote: Resolving deltas: 100% (9/9), completed with 7 local objects.
To https://github.com/ios-zhouyu/ZYCycleViewSwift
7846400..e90cd3d master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
1
2
3
4
5
6
7
8
9
10
11
12
————————————————
版权声明:本文为CSDN博主「上进求知,认真思辨」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/kuangdacaikuang/article/details/90146891
使用git push origin master是出现如下问题;
Username for 'https://github.com':
解决办法:
git remote set-url origin git+ssh://git@github.com/username/reponame.git
转载于:https://www.cnblogs.com/huangxingyuan/p/6492716.html
git remote set-url命令修改remote URL
git remote set-url传递两个参数
- remote name。例如,origin或者upstream
- new remote url。例如,git@github.com:USERNAME/OTHERREPOSITORY.git
例如:从SSH切换到HTTPS的远程URL
- 打开终端
- 切换到你项目的工作目录
- 列出remotes,是为了得到你想要改变的remote的名字
xxxxxx@xxxxxx:~/workspace/goal$ git remote -v origin git@github.com:xxxxxx/SpringBoot.git (fetch) origin git@github.com:xxxxxx/SpringBoot.git (push)
- 使用git remote set-url命令从SSH到HTTPS的远程URL
xxxxxx@xxxxxx:~/workspace/goal$ git remote set-url origin https://github.com/xxxxxx/SpringBoot.git
- 验证是否改变成功
xxxxxx@xxxxxx:~/workspace/goal$ git remote -v origin https://github.com:xxxxxx/SpringBoot.git (fetch) origin https://github.com:xxxxxx/SpringBoot.git (push)
Changing a remote's URL
The git remote set-url
command changes an existing remote repository URL.
Tip: For information on the difference between HTTPS and SSH URLs, see "Which remote URL should I use?"
The git remote set-url
command takes two arguments:
- An existing remote name, for example,
origin
- A new URL for the remote, for example:
https://github.com/USERNAME/REPOSITORY_2.git
if you're updating to use HTTPSgit@github.com:USER/REPOSITORY_2.git
if you're updating to use SSH
Switching remote URLs from SSH to HTTPS
- Open Terminal (for Mac and Linux users) or the command line (for Windows users).
- Change the current working directory to your local project.
-
List your existing remotes in order to get the name of the remote you want to change.
$ git remote -v # origin git@github.com:USERNAME/REPOSITORY.git (fetch) # origin git@github.com:USERNAME/REPOSITORY.git (push)
-
Change your remote's URL from SSH to HTTPS with the
remote set-url
command.$ git remote set-url origin https://github.com/USERNAME/REPOSITORY_2.git
-
Verify that the remote URL has changed.
$ git remote -v # Verify new remote URL # origin https://github.com/USERNAME/REPOSITORY2.git (fetch) # origin https://github.com/USERNAME/REPOSITORY2.git (push)
The next time you git fetch
, git pull
, or git push
to the remote repository, you'll be asked for your GitHub username and password.
- If you have two-factor authentication enabled, you must create a personal access token to use instead of your GitHub password.
- You can use a credential helper so Git will remember your GitHub username and password every time it talks to GitHub.
Switching remote URLs from HTTPS to SSH
- Open Terminal (for Mac and Linux users) or the command line (for Windows users).
- Change the current working directory to your local project.
-
List your existing remotes in order to get the name of the remote you want to change.
$ git remote -v # origin https://github.com/USERNAME/REPOSITORY.git (fetch) # origin https://github.com/USERNAME/REPOSITORY.git (push)
-
Change your remote's URL from HTTPS to SSH with the
remote set-url
command.git remote set-url origin git@github.com:USERNAME/REPOSITORY2.git
-
Verify that the remote URL has changed.
$ git remote -v # Verify new remote URL # origin git@github.com:USERNAME/REPOSITORY2.git (fetch) # origin git@github.com:USERNAME/REPOSITORY2.git (push)