簡體   English   中英

如何在Mercurial(hg)中列出存儲庫中的所有文件?

[英]How to list all files in a repository in Mercurial (hg)?

mercurial中是否有一個命令會列出當前受源代碼管理的所有文件?

我可以用dir /s列出我的文件夾和子文件夾中的所有文件,但我不知道哪些已添加到我的存儲庫中。 我有各種排除的文件類型和文件夾,我想驗證在我的.hgignore文件中設置它們之前沒有添加它們。

hg status --all將列出樹中的所有文件,並帶有一個表示其狀態的字母:M表示已修改,C表示清除(由hg擁有),I表示已忽略。

對於剛剛忽略的文件,請使用hg status -i 對於將在下次提交時添加的文件,請使用hg status -a 這些只顯示您需要知道的內容,不需要掃描長文件列表。

您也可以查看hg locate命令。 當我想將文件限制到某個目錄時,我使用它和-I選項。

列出存儲庫中的所有文件:

hg locate

從存儲庫(“root”)目錄:

hg locate -I dir/sub_dir/dir_of_interest

傳遞給-I的路徑需要根據運行命令的目錄進行更改。 如果您在上面的示例中從dir目錄運行命令,則需要修改您的參數以找到:

hg locate -I sub_dir/dir_of_interest

輸出文件列表將保持不變,顯示存儲庫中每個文件的完整路徑。

嘗試hg help -v locate以獲取更多信息。

hg manifest將僅列出存儲庫中的文件,而hg status --all將列出存儲庫結構中的所有文件,並包括正在跟蹤的標記和不標記的標記。

列出僅忽略或添加的文件

列出被忽略的文件,請執行: hg status -i

對於剛添加的文件,請執行hg status -a

如果你不喜歡打字,可以將它們縮短為hg sta -ihg sta -a

status這兩種用法比locate更簡單,並且會為您提供您關注的特定文件狀態,因此它更不容易出錯。

更多關於hg status

要列出mercurial repo中的所有文件,請執行以下操作: hg status --all

列出文件時,它們將在它們之前被賦予前綴:

  M = modified
  A = added
  R = removed
  C = clean
  ! = missing (deleted by non-hg command, but still tracked)
  ? = not tracked
  I = ignored

如果只想列出文件夾中的文件 ,可以提供以下路徑:

  • hg st --all MyFolder - hg st --all MyFolder所有文件
  • hg sta -i MyFolder - 只是忽略了MyFolder中的文件。

除了“Ignored”的-i和“已添加”的-a ,還有其他標志可用於僅列出具有特定狀態的文件。

獲得help

請閱讀其他非常有用的答案,以獲得有關status命令的全面說明。 由於作者試圖證明你可以通過 Mercurial 詢問有關status命令的信息來表明你可以發現以上所有內容,因此它的票數很低:

hg help status

您可以讓Mercurial告訴您這些命令的任何內容。 如果你想要一個Mercurial命令列表,那么輸入hg help

C:\>hg help -v status
hg status [OPTION]... [FILE]...

aliases: st

show changed files in the working directory

    Show status of files in the repository. If names are given, only files
    that match are shown. Files that are clean or ignored or the source of a
    copy/move operation, are not listed unless -c/--clean, -i/--ignored,
    -C/--copies or -A/--all are given. Unless options described with "show
    only ..." are given, the options -mardu are used.

    Option -q/--quiet hides untracked (unknown and ignored) files unless
    explicitly requested with -u/--unknown or -i/--ignored.

    NOTE: status may appear to disagree with diff if permissions have changed
    or a merge has occurred. The standard diff format does not report
    permission changes and diff only reports changes relative to one merge
    parent.

    If one revision is given, it is used as the base revision. If two
    revisions are given, the differences between them are shown. The --change
    option can also be used as a shortcut to list the changed files of a
    revision from its first parent.

    The codes used to show the status of files are:

      M = modified
      A = added
      R = removed
      C = clean
      ! = missing (deleted by non-hg command, but still tracked)
      ? = not tracked
      I = ignored
        = origin of the previous file listed as A (added)

options:

 -A --all             show status of all files
 -m --modified        show only modified files
 -a --added           show only added files
 -r --removed         show only removed files
 -d --deleted         show only deleted (but tracked) files
 -c --clean           show only files without changes
 -u --unknown         show only unknown (not tracked) files
 -i --ignored         show only ignored files
 -n --no-status       hide status prefix
 -C --copies          show source of copied files
 -0 --print0          end filenames with NUL, for use with xargs
    --rev             show difference from revision
    --change          list the changed files of a revision
 -I --include         include names matching the given patterns
 -X --exclude         exclude names matching the given patterns

global options:
 -R --repository      repository root directory or name of overlay bundle file
    --cwd             change working directory
 -y --noninteractive  do not prompt, assume 'yes' for any required answers
 -q --quiet           suppress output
 -v --verbose         enable additional output
    --config          set/override config option (use 'section.name=value')
    --debug           enable debugging output
    --debugger        start debugger
    --encoding        set the charset encoding (default: cp1252)
    --encodingmode    set the charset encoding mode (default: strict)
    --traceback       always print a traceback on exception
    --time            time how long the command takes
    --profile         print command execution profile
    --version         output version information and exit
 -h --help            display help and exit

暫無
暫無

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

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