【发布时间】:2021-01-27 09:03:02
【问题描述】:
我的存储库是 Porfolio3,我在 GitHub 上将其更改为 Portfolio(没有 3)。我还在努力,我不想失去它。我进入我的本地代码并像往常一样输入“git push”但我得到了这个:
D:\GitHub\01 Portfolio> git push
To https://github.com/moki929/Portfolio
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/moki929/Portfolio'
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.
我尝试了很多方法,例如:
PS D:\GitHub\01 Portfolio> git remote add origin-push $(git config https://github.com/moki929/Portfolio.git)
但我明白了
我的 git 状态:
PS D:\GitHub\01 Portfolio> git status
On branch master
Your branch is ahead of 'destination/master' by 3 commits.
(use "git push" to publish your local commits)
我尝试将起点重命名为目的地。认为这将解决它。我需要改回原点吗?我只想推送到 GitHub。
【问题讨论】:
-
git remote --set-url origin <url>呢? -
错误信息告诉你先同步遥控器。您可以先尝试
git fetch --all,然后再尝试git rebase origin/master或git merge origin/master。然后你可以再次尝试git push。 -
PS D:\GitHub\01 Portfolio> git fetch --all Fetching destination From github.com/moki929/Portfolio Fetching origin-push ...Portfolio> git rebase origin/master fatal: invalid upstream 'origin/master ' ...Portfolio> git merge origin/master merge: origin/master - 不是我们可以合并的东西 ...Portfolio> git push To github.com/moki929/Portfolio ! [rejected] master -> master (non-fast-forward) ... ...Portfolio> git remote --set-url origin github.com/moki929/Portfolio.git error: unknown option `set-url'
-
成功了!我不得不将其改回: git remote rename destination origin ... 上面的所有错误都没有再次发生。
标签: git github repository