无法将现有代码推送到新的git存储库

时间:2018-12-14 13:59:42

标签: git github

我从项目中获得了git储存库,我已经删除了.git文件。现在,我创建了一个新的git存储库,并尝试将代码推送到新的存储库中。为此,我使用了命令

  1. git init
  2. git add。
  3. git commit -m“”
  4. git remote add origin https://github.com/xxxx/project-sp.git
  5. git push -u原始主机

对于第5点,错误为

  
    

拒绝xxx / project-sp.git的权限。严重:无法访问“ 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 repo。我对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.

1 个答案:

答案 0 :(得分:0)

您可以按照git或bitbucket的文档进行操作。这是适用于me的doc链接