完整的信息:

error: Ref refs/remotes/origin/user is at 3636498c2ea7735fdcedc9af5ab3c8689e6abe77 but expected a21359c6cc2097c85775cde6a40105f4bd7100ec
From github.com:{github project url}
 ! a21359c..6273ffc  user -> origin/user  (unable to update local ref)

当前回答

我必须从命令行中删除我的分支:

.git\refs\remotes\{my remote}\{**my branch**}

然后手动操作:

git pull [remote_name] [branch_name]

我找到了改动的地方。

注意:我正在使用SourceTree,无法进行拉取。

其他回答

只需删除\.git\refs\remotes\origin下的文件夹和文件。 工作,当你没有未推送的更改。

我尝试了多种选择,但没有一个对我有效。下面的命令对我很有用。把它放在这里,如果它能帮助人们,以防其他选择不起作用。

Git拉-p

-p --prune Before fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning. Supplying --prune-tags is a shorthand for providing the tag refspec.

——来源:https://git-scm.com/docs/git-pull文档/ git-pull.txt——p

清晰的步骤

在终端 cd / . / /遥控器/参考文献来源 做ls,你会看到一些树枝和头部 移除你认为有问题的分支 rm branchname 如果它不起作用,删除所有分支/HEAD 你可能想拉一把

希望它现在有用。

我必须从命令行中删除我的分支:

.git\refs\remotes\{my remote}\{**my branch**}

然后手动操作:

git pull [remote_name] [branch_name]

我找到了改动的地方。

注意:我正在使用SourceTree,无法进行拉取。

同样的情况在这里,但没有关于张贴的评论在我的情况下是正确的,我只有一个分支(master),只使用Unix文件系统,这个错误随机发生时,我运行git fetch -progress -修剪起源和分支是前方或'origin/master'。没有人可以提交,只有1个用户可以推送。

注意:我在acme存储库中有一个子模块,acme有新的子模块更改(新提交),我需要先用git子模块更新做一个子模块更新。

[2014-07-29 13:58:37] Payload POST received from Bitbucket
[2014-07-29 13:58:37] Exec: cd /var/www/html/acme
---------------------
[2014-07-29 13:58:37] Updating Git code for all branches
[2014-07-29 13:58:37] Exec: /usr/bin/git checkout --force master
[2014-07-29 13:58:37] Your branch is ahead of 'origin/master' by 1 commit.
[2014-07-29 13:58:37]   (use "git push" to publish your local commits)
[2014-07-29 13:58:37] Command returned some errors:
[2014-07-29 13:58:37] Already on 'master'
---------------------
[2014-07-29 13:58:37] Exec: /usr/bin/git fetch --progress --prune origin
[2014-07-29 13:58:39] Command returned some errors:
[2014-07-29 13:58:39] error: Ref refs/remotes/origin/master is at 8213a9906828322a3428f921381bd87f42ec7e2f but expected c8f9c00551dcd0b9386cd9123607843179981c91
[2014-07-29 13:58:39] From bitbucket.org:acme/acme
[2014-07-29 13:58:39]  ! c8f9c00..8213a99  master     -> origin/master  (unable to update local ref)
---------------------
[2014-07-29 13:58:39] Unable to fetch Git data

要解决这个问题(在我的例子中),如果你的分支在原点之前,只需运行第一个git push。