1. 12
  1.  

  2. 2

    git jump is an optional tool that ships with Git in its contrib directory. git jump wraps other Git commands, like git grep and feeds their results into Vim’s quickfix list. This makes it possible to write something like git jump grep foo and have Vim be able to quickly navigate between all matches of “foo” in your project.

    I’m an Emacs user, but can’t you use git grep directly in vim by setting grepprg? ie. :set greprg git\ grep. It seems the jump merge and diff commands are the ones that are more valuable.

    1. 2

      You would need to set grepprg to (e.g.) grepprg=git\ grep\ -n\ --column, but you probably wouldn’t want that all the time (only when working in git repositories and even then only in some circumstances). At other times, you’d probably want to set grepprg to something else (e.g., I set mine to ripgrep). So even for grep, git jump may be a helpful convenience.

      While we are (sort of) on the subject, this gist has an excellent (and very small) set of tweaks to make grep work better in {neo,}vim.

    2. 2

      check-attr is used to determine which gitattributes are set for a given path. These attributes are defined and set by one or more .gitattributes file(s) in your repository.

      [but in a bare repo, there is no working directory in which to look for a .gitattributes file]

      In Git 2.40, check-attr supports a new –source= to scan for .gitattributes in, meaning that the following will work as an alternative to the above, even in a bare repository:

      $ git check-attr -a --source=HEAD^{tree} git.c
      

      Does anybody else feel this flag was named from an implementer’s perspective, rather than a user’s perspective?

      • check-attr’s internally needs a source of .gitattribute files — normally the working dir, but that’s absent in a bare repo. So (the developer of) check-attr tells the user “Hey user, if you want me to check attributes in a bare repo, you have to give me a source of info: point me at the right filetree with this flag/command:”

        --source=Commit^{tree}
        git check-attr -a --source=Commit^{tree} File
        
      • But from the user’s point of view, they’re asking “Hey git, what are the attributes of file F in commit C?” And from that perspective, you’d expect a flag/command like this:

        --commit=Commit 
        git check-attr -a --commit=Commit File