GIT-LFS-COMPLETION(1)
π GIT-LFS-COMPLETION(1) π
okay so bestie, this is the manual page for git-lfs-completion β the whole point is generating shell tab-completion scripts for Git LFS. iykyk β¨
π¦ NAME π¦
git-lfs-completion β Shell tab-completion script generation for Git LFS.
π οΈ SYNOPSIS π οΈ
git lfs completion bash
git lfs completion fish
git lfs completion zsh
π DESCRIPTION π
Okay so this command outputs a script which, when executed in a session of the given shell, will implement command-line tab-completion of Git LFS commands. periodt β¨
Each shell requires a different set of commands to load the completion script, either for an individual session or automatically whenever a new session is started. See the EXAMPLES section for details. π
The script for each shell provides tab-completion of Git LFS command names and flags, but does not offer completion of Git terms such as the names of Git remotes, branches, or tags. (This may change in a future release of Git LFS.) no cap π
By default, each shellβs script supports Git LFS command completion when prompted with a tab character entered following the program name git-lfs. For instance, git-lfs [Tab] will list the available Git LFS commands such as fetch, migrate, and pull, and git-lfs pull --[Tab] will list the possible flags for the git-lfs-pull(1) command. it's giving magic πͺ
However, most users will be accustomed to using Git LFS as a program invoked by Git, e.g., git lfs checkout or git lfs pull. To enable tab-completion of Git LFS commands in this case, tab-completion for regular Git commands must be active as well. Assuming this is true, the scripts generated by the git lfs completion command should support completion of Git LFS commands when a tab character is entered following git lfs, such as git lfs [Tab] to list all available Git LFS commands or git lfs pull --[Tab] to list that commandβs possible flags. See the SHELLS section for details regarding Git tab-completion in the supported shells. π
As is common for shell tab-completion, a space must be entered after the git-lfs or git lfs command names before the tab character will cause the Git LFS completion script to be executed. Without the space character, any active shell tab-completion will instead search for programs whose names have a matching prefix. the more you know π
The completion scripts make use of "hidden" Git LFS commands to request completion results from the Git LFS client, specifically the git lfs __complete and git lfs __completeNoDesc commands.
β οΈ These commands may be removed in the future, or their action may be altered without notice, and so users should not call them directly or consider them to be part of the officially documented Git LFS command-line interface. fr fr, do not touch π
π SHELLS π
The git lfs completion command supports three Unix shells, GNU Bash (Bourne Again SHell), fish, and Zsh (Z shell). Tab-completion is configured differently in each, both in general and specifically for Git and therefore also for Git LFS. vibe check: each shell does its own thing β¨
On Windows, users who have Git LFS installed as part of the Git for Windows project have access to an emulation of the Bash shell which is packaged with Git for Windows. πͺ
- Bash: the classic π
- While Bash does not offer tab-completion for Git by default, a completion script is available from the Git project, as described in the documentation:
https://git-scm.com/book/en/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Bashπ - The script returned by the
git lfs completion bashcommand should be compatible with this Git completion script and allow for tab-completion of Git LFS commands entered using either thegit lfsorgit-lfscommand formats. slay β - After retrieving a copy of the Git completion script appropriate to your version of Git, run the following command to load the script in your current session:
$ source git-completion.bashπ«Ά - To load the script in all future sessions, add this command to your Bash startup files, or place the file in one of the locations searched by the utilities from the
bash-completionpackage. set it and forget it β¨ - The
bash-completionproject, which is separate from the GNU Bash shell itself, includes a large number of command completion scripts and utilities to load them automatically when starting a new session:https://github.com/scop/bash-completionπ - The Git LFS completion script for Bash depends on several functions provided by the
bash-completionpackage, and so that package must be installed in order to use tab-completion with Git LFS commands. (It is not required by the Git completion script for Bash, however.) important bestie β οΈ - Assuming the
bash-completionpackage is installed, to load the Git completion script in all future sessions started by the current user (but not all users), place thegit-completion.bashscript in thebash-completion/completionsdirectory within the location defined by theXDG_DATA_HOMEenvironment variable, or, if that variable is not defined, the~/.local/sharedirectory. For example:$ cp git-completion.bash ~/.local/share/bash-completion/completions/gitπ - For the
bash-completionutilities to load the Git completion script for all users, place the Git completion script in the appropriate system directory. On Linux this may be/usr/share/bash-completion/completions, and on macOS, whenbash-completionis installed using Homebrew, it may be theshare/bash-completion/completionsdirectory within the location returned by thebrew --prefixcommand. However, these locations will vary depending on how thebash-completionpackage was installed. homebrew girlies know πΊ
- While Bash does not offer tab-completion for Git by default, a completion script is available from the Git project, as described in the documentation:
- fish: the friendly one π
- The
fishshell provides its own implementation of Git command tab-completion, defined in agit.fishfile which is likely present by default in the list of locations the shell searches for completion scripts. cute π«§ - The script returned by the
git lfs completion fishcommand should be compatible with this implementation and allow for tab-completion of Git LFS commands entered using either thegit lfsorgit-lfscommand formats. works either way β
- The
- Zsh: the customizable icon π
- To enable tab-completion in Zsh for any commands, the
compinitfunction must be loaded first with a command similar to the following:% autoload -Uz compinit && compinitβ‘ - This may be done individually for each session, or added to a startup file such as
~/.zshrcor/etc/zshrcso it will apply to all future sessions, either for the current user or for all users. π - Zsh reads completion functions from the locations specified in the
FPATHenvironment variable, with the paths listed first taking precedence. This list is also available as an array in thefpathvariable; the shell automatically synchronizesFPATHandfpath. the way that works π - The Z shell provides its own implementation of Git command tab-completion, defined in a
_gitfile which is likely present in one of the locations specified infpath. ποΈ - The script returned by the
git lfs completion zshcommand should be compatible with this implementation and allow for tab-completion of Git LFS commands entered using either thegit lfsorgit-lfscommand formats. compatible queen π - The Git project also offers completion scripts for Zsh, in the form of the same
git-completion.bashscript used for the Bash shell, plus agit-completion.zshscript which is intended to be renamed to_gitand placed in a location listed infpath. These scripts are not compatible with the one returned by thegit lfs completion zshcommand, and if they used in conjunction with that script, tab-completion of Git LFS commands will not function properly when initiated using thegit lfscommand format. don't mix them, bestie π - On macOS, if Git is installed using Homebrew, the Git projectβs Zsh completion scripts may be installed in a location where they take precedence over the implementation provided by Zsh. In this case, to make full use of the script returned by
git lfs completion zsh, the_gitcompletion script file installed by Homebrew for Git must be moved or removed so it does not precede the Z shellβs own Git completion script in the path order specified byfpath. macOS Homebrew drama, but make it completion π
- To enable tab-completion in Zsh for any commands, the
β¨ EXAMPLES β¨
Loading completions for the current shell session π«Ά
okok so if you just want the completions right now, for this session only, no forever-commitment?? you literally just execute the script that git lfs completion spits out. that's it. that's the whole vibe. let's go shell by shell π
- Bash β source the output with a process substitution:
$ source <(git lfs completion bash)
β οΈ lowkey important: on Bash 3.2, the source builtin command will not properly execute the output of a process substitution π so you gotta use a temporary file instead:
$ git lfs completion bash >git-lfs-completion.bash
$ source git-lfs-completion.bash
- fish β pipe it straight into
source:
> git lfs completion fish | source
- zsh β same process-substitution slay, but heads up: the
compinitfunction must also be executed to enable tab-completion, as described in the SHELLS section π
% source <(git lfs completion zsh)
Automatically loading completions for future shell sessions π
want it forever? main character energy? then you store the script that git lfs completion generates somewhere your shell actually reads during session startup. set it and forget it, bestie β¨
- Bash β okay so as mentioned in the SHELLS section, the
bash-completionpackage is required by the Git LFS completion scripts for Bash. and bonus: it also provides convenient utilities which search for completion scripts in a set of defined locations and execute them during session startup π«‘
to load the Git LFS completion script in all future sessions started by the current user (but not other users), store the script in the bash-completion/completions directory within the location defined by the XDG_DATA_HOME environment variable, or, if that variable is not defined, the ~/.local/share directory. like this:
$ mkdir -p ~/.local/share/bash-completion/completions
$ git lfs completion bash >~/.local/share/bash-completion/completions/git-lfs
to load the completion script in all users' future sessions, store the script instead in an appropriate system directory β which on Linux may be /usr/share/bash-completion/completions, or on macOS, if bash-completion was installed using Homebrew, may be the share/bash-completion/completions directory within the location returned by the brew --prefix command. these locations will vary depending on how the bash-completion package was installed and configured, however π
so for details, check the documentation relevant to your system's bash-completion package.
- fish β the fish shell searches for completion scripts in a number of locations, as described in the documentation:
https://fishshell.com/docs/current/completions.html#where-to-put-completions
to load the Git LFS completion script in all sessions started by the current user (but not other users), store the script in the fish/completions directory within the location defined by the XDG_CONFIG_HOME environment variable, or, if that variable is not defined, the ~/.config directory. for example:
> mkdir -p ~/.config/fish/completions
> git lfs completion fish >~/.config/fish/completions/git-lfs.fish
to load the completion script in all users' future sessions, store the script in one of the other locations searched by the shell, such under fish/completions within the shell's system configuration directory. on Linux this is typically /etc/fish/completions. on macOS, when the fish shell is installed using Homebrew, this would normally be the etc/fish/completions directory within the location returned by the brew --prefix command π
- zsh β again, the
compinitfunction must also be executed to enable tab-completion, as described in the SHELLS section. don't skip it, i'm begging π
to load the Git LFS completion script in all sessions, store the script as a file named _git-lfs in one of the locations listed in the fpath variable. the specific location you pick may affect whether the completion script is loaded only for sessions started by the current user or for all users' sessions, depending on how the set of paths in the fpath array is constructed. iykyk π
the following command will store the script in the first location defined in fpath:
% git lfs completion zsh >"${fpath[1]}/_git-lfs"
you may also prefer to store the file in another location defined in fpath, for instance, the last location, in which case ${fpath[-1]} should be used instead. dealer's choice π
it is also possible to add a custom location to the list in fpath and store the Git LFS completion script there. to do this, add the commands that update the fpath variable to a startup file such as ~/.zshrc or /etc/zshrc so they will apply to all future sessions β either for the current user or for all users π¦
π SEE ALSO π
part of the git-lfs(1) suite. the whole iconique family, fr fr π
okay that's the whole page bestie, no gatekeeping π this footer is literally GIT-LFS-COMPLETION(1) β straight from the git-lfs source, version and date exactly as your build ships them, periodt π«Ά
π¦ where this page comes from
- arch rolling: git-lfs 3.8.1-1 Β· MIT
- nixos 26.05: git-lfs 3.8.1
- nixpkgs unstable: git-lfs 3.8.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms