【发布时间】:2018-12-14 22:46:31
【问题描述】:
我有来自项目的git 存储库我删除了.git 文件。现在我创建了一个新的 git 存储库并尝试将代码推送到新的存储库中。为此,我使用了命令
- git 初始化
- git 添加。
- git commit -m ""
- git远程添加源https://github.com/xxxx/project-sp.git
- git push -u origin master
对于第 5 点,错误为
xxx/project-sp.git 的权限拒绝给 xxxx。致命:无法访问“https://github.com/xxx/project-sp.git/”:请求的 URL 返回错误:403
然后我从凭据管理器中删除了 git 凭据并使用了命令git pull
我收到的消息是
warning: no common commits
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/xxx/project-sp
* [new branch] master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
我应该怎么做才能将代码推送到新的 git 存储库。我对 git 很陌生。我该如何解决这个问题?
更新:当我尝试使用命令 git push --set-upstream origin master 时,我收到一个错误,因为
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/xxx/project-sp.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
【问题讨论】:
-
你确定你可以访问这个仓库吗?您是否尝试过配置 RSA 密钥?
-
是的,当我使用 cmd
git push时,我已经登录了。什么是 RSA 密钥我是 git 环境的新手。