簡體   English   中英

如何用遠程倉庫中的另一個替換本地倉庫中的文件?

[英]How to replace a file in local repo with another one from remote repo?

我確實嘗試了很多方法,但是我不了解實際情況以及如何解決該問題:

有兩個git repos:遠程和本地(在我的機器上)。 自從我學習以來,我一直在嘗試代碼並在本地文件中進行許多更改。 通常,然后我對每個已更改的文件執行還原操作,然后從遠程存儲庫中提取項目的實際版本。 但是現在我有一個文件(例如hello.jsp )被我更改了,並且這些更改已提交。 在那之后,我做了幾次與其他文件相關的其他更改。 好吧,現在我想用遠程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”?

嘗試簽出所需的文件。 您必須從所需位置指定位置。

git checkout your_remote/your_branch filename

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM