如何用远程仓库中的另一个文件替换本地仓库中的文件?

时间:2013-09-20 08:07:37

标签: git git-pull

我确实尝试了很多方法,但我没有得到真正发生的事情以及如何解决它:

有两个git repos:远程和本地(在我的机器上)。 因为我正在学习我实验代码并在我的本地文件中做了很多更改。通常然后我对每个已更改的文件进行恢复,然后从远程仓库中提取实际版本的项目。 但是现在我有一个由我更改的文件(例如hello.jsp)并且已经提交了这些更改。之后我几次提交了与其他文件相关的其他更改。 那么现在我想用远程仓库中的相同文件替换我的本地hello.jsp。所以我做了git pull --rebase并且发生了合并冲突:

Applying: merge fixed
Using index info to reconstruct a base tree...
M       hello.jsp
<stdin>:10: trailing whitespace.
    function showHello() {
<stdin>:11: trailing whitespace.

<stdin>:12: trailing whitespace.
        document.getElementById('q').style.display = 'none';
<stdin>:13: trailing whitespace.
        document.getElementById('w').style.display = 'none';
<stdin>:14: trailing whitespace.
        document.getElementById('e').style.display = '';
warning: squelched 120 whitespace errors
warning: 125 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging hello.jsp
CONFLICT (content): Merge conflict in hello.jsp
Failed to merge in the changes.
Patch failed at 0001 merge fixed
The copy of the patch that failed is found in:
   d:/repo/helloProject/.git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

嗯..首先我尝试手动删除我记得的所有更改。但即使我使用某种“show diff”,也需要花很多时间才能找到所有细节(相信我“hello.jsp”非常庞大) 对我感到羞耻,但我现在无法做什么。

我尝试git reset "hello.jsp"并试图git checkout "hello.jsp",但它没有用。如何简单地用远程仓库中的另一个替换我的“hello.jsp”?

1 个答案:

答案 0 :(得分:1)

尝试签出您想要的文件。你必须从你想要的地方指定地点。

git checkout your_remote/your_branch filename
相关问题