谁能解释我的存储库的状态?我无法推送,因为我没有的服务器上有更改,但我无法变基,因为 git 告诉我没有新的更改。
$ git branch
* master
$ git push origin master
To git@github.com:asdf.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:asdf.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.
$ git fetch origin master
From github.com:knowitall/nlptools
* branch master -> FETCH_HEAD
$ git rebase origin master
Already on 'master'
Your branch is ahead of 'origin/master' by 3 commits.
Current branch master is up to date.
$ git pull origin master
它建议的合并是空的。
Merge branch 'master' of github.com:knowitall/nlptools
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
如果我创建一个分支,用 origin/master 重置,然后合并分支,我仍然无法推送。
$ git checkout -b backup
$ git checkout master
$ git fetch origin master
$ git reset origin/master --hard
$ git merge backup
$ git push origin master
! [rejected] master -> master (non-fast-forward)
现在,如果 Ireset
和pull
,我会看到一个新的提交。为什么一开始没有fetch origin master
找到这个新的提交?如何确保我的存储库表示来源是最新的?看来我需要成功拉动才能使源保持最新。