我意识到我设置user.name错了,所以我使用这个答案来修复不正确的提交.在当地,它运作良好.但是,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
Run Code Online (Sandbox Code Playgroud)
所以,现在我需要以某种方式将我的更改发送到我的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.
Run Code Online (Sandbox Code Playgroud)
我不太确定如何解决这个问题.我以前处理过远程更改,并通过拉动和合并来解决它们,但我不知道在这种情况下该怎么做.我需要用更正的名称更新我的GitHub存储库,我该怎么做?
史蒂文的回答是正确的,但非常危险.因此在使用强制推动时要小心.
首先,git push -f将强制将所有本地分支推送到远程存储库.
要只推送主分支,您必须指定它.
git push -f origin master
Run Code Online (Sandbox Code Playgroud)
执行此操作时,您将希望告诉所有其他有权访问此存储库的人在进行任何其他提交之前下拉您的更改.否则,分支机构会以你不想处理的疯狂方式发散.