git push merge错误,但git pull已经是最新的。尝试reclone,同样的问题 [英] git push merge error, but git pull is already up-to-date. Tried reclone, same problem
问题描述
我这样做:
$ git commit。
$ git push
错误:条目'file.php'不是uptodate。无法合并。
然后我做了
$ git pull
已经是最新的。
我该怎么办?我只想从远程副本获取最新版本,并覆盖本地副本上的任何内容。
编辑:我尝试了一切。我删除了我的本地仓库,并且
pre $ git克隆ssh://root@something.com/directory
。 ..
检出文件:100%完成。
$ git status
关于分支大师
没有提交(工作目录清理)
一切看起来不错,对吧?以防万一。
$ git pull
已经是最新的。
我在文件中进行一行更改,以查看是否可以推送它。
$ git commit。
[master 1e18af1] Rando更改
更改了1个文件,2个插入(+),0个删除( - )
$ git push
计数对象:13,完成。
使用多达2个线程的增量压缩。
压缩对象:100%(6/6),完成。
写入对象:100%(7/7),646字节,完成。
合计7(delta 3),重用0(delta 0)
从/目录
d6d61aa..1e18af1 master - >起源/主
错误:条目'someotherfile.php'不是uptodate。无法合并。
更新b8f9a54..1e18af1
至ssh://root@something.com/directory
d6d61aa..1e18af1主 - > master
我有不知道发生了什么!我怎样才能正常提交/再次拉?
这仅仅是一个预感,但是您的远程是一个裸机还是工作目录?如果它是一个工作目录而不是裸露的repo,则远程上的 file.php
文件具有未提交的更改。您的 git push
命令试图在远程导致 HEAD
,导致由于未提交的更改而导致冲突。 / p>
这就是为什么您通常 git pull
来更新工作目录,并使用 git push
在裸回购。仅供参考,要设置一个裸回购作为类似于中央CVS / SVN / etc回购的东西,请在遥控器上执行以下操作:
$ mkdir my-git-repo
$ cd my-git-repo
$ git init --bare
然后在你的本地仓库中:
$ cd my-git-repo.git
$ git remote add origin user @ host :/ path / to / my-git-repo /
$ git config branch.master.remote origin
$ git config branch.master.merge refs / heads / master
$ git push origin master
现在你有一个裸仓库,可以从你的主分支中推/拉入。您可以使用任何其他需要放置在远程的本地分支来重复最后三个本地步骤。克隆与以前一样,您不需要使用 git config
,因为遥控器会自动设置,并且在使用跟踪分支时会设置远程合并参考。
希望有帮助。
I do:
$ git commit .
$ git push
error: Entry 'file.php' not uptodate. Cannot merge.
Then I do
$ git pull
Already up-to-date.
What do I do? I just want to get the latest version from the remote copy, and overwrite anything on my local copy.
Edit: I tried everything. I deleted my local repo, and
$ git clone ssh://root@something.com/directory
...
Checking out files: 100%, done.
$ git status
On branch master
nothing to commit (working directory clean)
All looks good, right? Pull just in case.
$ git pull
Already up-to-date.
I make a one line change in a file to see if I can push it.
$ git commit .
[master 1e18af1] Rando change
1 files changed, 2 insertions(+), 0 deletions(-)
$ git push
Counting objects: 13, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 646 bytes, done.
Total 7 (delta 3), reused 0 (delta 0)
From /directory
d6d61aa..1e18af1 master -> origin/master
error: Entry 'someotherfile.php' not uptodate. Cannot merge.
Updating b8f9a54..1e18af1
To ssh://root@something.com/directory
d6d61aa..1e18af1 master -> master
I have no idea what's going on! How can I commit/pull again normally? Thanks very much!
This is just a hunch, but was your remote a bare repo or a working directory? If it was a working directory rather than a bare repo, the file.php
file on the remote had uncommitted changes. Your git push
command was trying to advance the HEAD
at the remote which was causing conflicts due to the uncommitted changes.
This is why you usually git pull
to update a working directory, and use git push
on bare repos. FYI, to setup a bare repo for use as something similar to a central CVS/SVN/etc repo, do the following on the remote:
$ mkdir my-git-repo $ cd my-git-repo $ git init --bare
Then in your local repo:
$ cd my-git-repo.git $ git remote add origin user@host:/path/to/my-git-repo/ $ git config branch.master.remote origin $ git config branch.master.merge refs/heads/master $ git push origin master
Now you have a bare repo to push/pull into/from that contains your master branch. You can repeat the last three local steps with any additional local branches you want to put on the remote. Cloning is the same as before and you don't need to use git config
as remotes are set automatically and remote merging refs are set when you use tracking branches.
Hope that helps.
这篇关于git push merge错误,但git pull已经是最新的。尝试reclone,同样的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!