【问题标题】:How to tell mercurial to 1. Discard local file 2. Use remote file如何告诉 mercurial 1. 丢弃本地文件 2. 使用远程文件
【发布时间】:2012-07-24 14:37:51
【问题描述】:

有时我似乎无法跟踪合并冲突。 我需要一个命令,允许我丢弃其中一个未提交的文件,然后使用远程副本对其进行更新。

我试过 hg revert myfile 然后是 hg pull , hg commit 但它仍然不允许我合并或提交。

它一直告诉我先解决未解决的冲突。

【问题讨论】:

    标签: mercurial conflict


    【解决方案1】:

    您可能需要使用hg resolve 让 Mercurial 知道您已解决冲突。从手册页:

    hg resolve [OPTION]... [FILE]...
    
    redo merges or set/view the merge status of files
    
      Merges with unresolved conflicts are often the result of non-interactive
      merging using the "internal:merge" configuration setting, or a command-
      line merge tool like "diff3". The resolve command is used to manage the
      files involved in a merge, after "hg merge" has been run, and before "hg
      commit" is run (i.e. the working directory must have two parents). See "hg
      help merge-tools" for information on configuring merge tools.
    
      The resolve command can be used in the following ways:
    
      - "hg resolve [--tool TOOL] FILE...": attempt to re-merge the specified
        files, discarding any previous merge attempts. Re-merging is not
        performed for files already marked as resolved. Use "--all/-a" to select
        all unresolved files. "--tool" can be used to specify the merge tool
        used for the given files. It overrides the HGMERGE environment variable
        and your configuration files.  Previous file contents are saved with a
        ".orig" suffix.
      - "hg resolve -m [FILE]": mark a file as having been resolved (e.g. after
      having manually fixed-up the files). The default is to mark all
      unresolved files.
      - "hg resolve -u [FILE]...": mark a file as unresolved. The default is to
        mark all resolved files.
      - "hg resolve -l": list files which had or still have conflicts. In the
        printed list, "U" = unresolved and "R" = resolved.
    
      Note that Mercurial will not let you commit files with unresolved merge
      conflicts. You must use "hg resolve -m ..." before you can commit after a
      conflicting merge.
    

    这是从服务器获取文件版本的方法。 当您“hg pull”时,来自服务器的所有更改都会进入您的存储库副本。您可以使用以下命令获取任何修订版中文件的内容:

    hg cat -r <rev> <file>
    

    使用它来覆盖本地文件,然后提交。

    【讨论】:

    • 是的,我可以使用工具来解决(我所要做的就是选择从服务器中提取的文件)。有没有办法在不使用该工具的情况下实现相同的目标?
    • "hg resolve" 不必使用工具:您可以使用 "-m" 将文件标记为已解决。还是我误解了你的问题?
    • 在标记为已解决之前,我需要拥有正确的文件(服务器中的文件)。我需要使用远程副本更新我的本地副本。我不想合并。我的本地文件需要被丢弃。
    • 当您“hg pull”时,来自服务器的所有更改都会进入您的存储库副本。您可以使用“hg cat -r ”获取任何修订版中文件的内容。使用它来覆盖本地文件,然后提交。
    • 酷彼得(+1)。正是我想要的。
    猜你喜欢
    • 2011-09-07
    • 2011-04-06
    • 2011-09-03
    • 2011-05-30
    • 2022-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多