The steps are as follows:
1, download Git-completion.bash or directly use Sourcetree to clone to local.
: https://github.com/markgandolfo/git-bash-completion
2. From the downloaded Git-bash-completion folder, locate Git-completion.bash and copy the file to ~/(copy this file to your own user home directory) and rename it to. Git-completion.bash (in. The file named at the beginning is a hidden file that can be prevented from being accidentally deleted)
3. If you do not have a. bashrc file in your user home directory (~/), create a new one and add the following to the. bashrc file:
SOURCE ~/.git-completion.bash
Then save the. bashrc file, note that if you want to take effect immediately, you can generally try the following:
(1) Exit the terminal and restart;
(2) if (1) is unsuccessful, you can run the following command at the command line immediately: source ~/.git-completion.bash
4, but after the setup of step 3, there may be a disadvantage, that is, each time you restart the terminal, you need to execute the following command: source ~/.git-completion.bash to take effect.
Improvement: In the. bash_profile file, add the following code.
if Then ~/.git-completion.bashfi
Mac git command auto-complete