Git 您所在的位置:网站首页 git查看所有版本 Git

Git

2023-10-01 20:32| 来源: 网络整理| 查看: 265

git ls-files 仅打印当前工作目录中的文件。

例如,如果您有一个用于dotfiles(core.worktree = /)的git repo ,那么您将在git root之外拥有文件,该简单命令将不再起作用。

简而言之,这将起作用:

git --git-dir "`git rev-parse --git-dir`" \ -C "`git config core.worktree || pwd`" \ ls-files

例:

mkdir ~/dotfiles cd ~/dotfiles git config core.worktree / # Ignore all files by default, else Git will find all files under "/" echo "*" > .git/info/exclude # Add files at the git repo's root and somewhere in the work tree touch README git add -f README git add -f /etc/ssh/sshd_config # `git status` would now print: # new file: ../../../etc/ssh/sshd_config # new file: README git status git commit -m "Initial commit" # At this point, `git ls-files` prints only: # README git ls-files # But you can print all files inside the work tree. This will print: # etc/ssh/sshd_config # home/yourusername/dotfiles/README git --git-dir "`git rev-parse --git-dir`" -C "`git config core.worktree || pwd`" ls-files

如果要指定相对于当前(shell)目录的路径,则可以执行以下操作:

alias gls='git ls-tree -r master --name-only HEAD "`git config core.worktree`"'

在上面的示例中,它将打印

README ../../../etc/ssh/sshd_config


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有