【问题标题】:Setting git hist to pretty print log via an alias on Windows通过 Windows 上的别名将 git hist 设置为漂亮的打印日志
【发布时间】:2014-06-24 21:53:19
【问题描述】:

这样做:

git config --global alias.hist 'log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'

as mentioned 在 Windows 机器上只是给了我 这个错误:

usage: git config [options]

当我尝试运行 git hist 时。有什么建议为什么它不起作用?

【问题讨论】:

    标签: windows git powershell


    【解决方案1】:

    PowerShell 正在用最后一个参数做一些有趣的事情。你可以像这样停止 所以

    git config --global alias.hist --% 'blah blah blah'
    #                              ^
    #                             / 
    #                  notice ----
    

    Powershell command line parameters and '--'

    【讨论】:

      【解决方案2】:

      我无法选择将hist 别名添加到git 的命令。但是我直接将它插入到.gitconfig 文件中,该文件通常可以位于"C:\Users\<login name>\""C:\Documents and Settings\<login name>\"

      查看我的.gitconfig 文件的片段,并注意对hist 别名所做的更改,以便它在Windows 下正常工作。

      [alias]
          co = checkout
          ci = commit
          st = status
          br = branch
          hist = !git --no-pager log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
          type = cat-file -t
          dump = cat-file -p
      

      【讨论】:

      • 我在“格式”之后忘记了这个\,这是错误
      【解决方案3】:

      使用双引号:

      git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-22
        • 2021-11-06
        • 2019-07-16
        • 2021-10-10
        • 2013-01-20
        • 1970-01-01
        • 2022-07-30
        • 2021-05-18
        相关资源
        最近更新 更多