简体   繁体   中英

Unable to push the existing code to a new git repository

I have git repository from the project I have deleted the .git file. Now I have created a new git repository and tried to push the code into the new repo. To do that I have used the command

  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 origin master

For the 5th point, the got an error as

Permission to xxx/project-sp.git denied to xxxx. fatal: unable to access ' https://github.com/xxx/project-sp.git/ ': The requested URL returned error: 403

Then I have removed the git credentials from the Credential Manager and used the command git pull I got the message as

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

What should I do to push the code to the new git repo. I'm very new to the git. How do I solve this issue?

Update: When I'm trying to use command git push --set-upstream origin master I'm getting an error as

 ! [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.

您可以按照git或bitbucket的文档进行操作。以下是对有用的doc链接

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM