我意识到我错误地设置了user.name
,所以我使用this answer来修复错误的提交。在当地,它运作良好。但是,git现在告诉我
$ git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 15 and 15 different commits each, respectively.
# (use "git pull" to merge the remote branch into yours)
#
nothing to commit, working directory clean
所以,现在我需要以某种方式将我的更改发送到我的GitHub存储库,但是当我推送时:
$ git push
WARNING: gnome-keyring:: couldn't connect to: /run/user/mspencer/keyring-uscL41/pkcs11: No such file or directory
Username for 'https://github.com': iBeliever
Password for 'https://iBeliever@github.com':
To https://github.com/iBeliever/weather-desktop.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/iBeliever/weather-desktop.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
我不太确定如何解决这个问题。我以前处理过远程更改,并通过拉动和合并来解决它们,但我不知道在这种情况下该怎么做。我需要使用更正的名称更新我的GitHub存储库,我该怎么做?
答案 0 :(得分:5)
首先,git push -f
将强制将所有本地分支推送到远程存储库。
要推送主分支,必须指定它。
git push -f origin master
执行此操作时,您需要告知可以访问此存储库的所有其他人在进行任何其他提交之前下拉您的更改。否则,分支机构会以你不想处理的疯狂方式发散。
答案 1 :(得分:1)
您 can force 推送
git push -f
更多信息
-f, --force Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables the check. This can cause the remote repository to lose commits; use it with care.