Question

I am reading the book "progit". It tells me that I can use auto completion script under bash. But I'm not quite understand what benefit I can get from it. Was it automatically push my local git change to a remote git sever?

Was it helpful?

Solution

No, the purpose of auto-completion is to reduce the amount of typing that you have to do at the command line, thus saving you time and energy. When you enable Git auto-completion for your shell (such as Bash of zsh), many commands can be auto-completed for you by simply typing the first few characters of a command, then hitting the tab key to complete it.

For example, if you type

$ git chec

and then hit tab, auto-completion should complete the command as

$ git checkout

saving you the effort of typing the last 4 characters, kout.

OTHER TIPS

I didn't care about Git auto-completion for a long time: the commands are short enough, and I created even shorter aliases for many of them.

But there are things you can't create aliases for, such as remote names and branch names, for example in these commands:

git fetch that-other-guy
git log that-other-guy/some-freakin-awesome-feature
git merge that-other-guy/some-freakin-awesome-feature

When collaborating with others, I like to use the same name for the remote of the other guy as his username on GitHub. Which can be long. In the past I used to be so lazy, if I had to do many operations on his remote, I would temporarily rename it to x to make it easier.

Similarly, feature branches are good to name in a way that captures their purpose, which can easily become a bit long, or sometimes even very long.

So after I played with the remote and branch name auto-completion in Git Bash where it's automatically setup correctly, I made sure to set it up in all my home systems as well (here's my very recent article for doing this on a mac).

So yeah, Git auto-completion totally rocks, I should have done it sooner.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top