Occasionally, I saw a colleague using git co feat/xxx
to operate git. I thought co was a new git command. It looked awesome, so I asked chatgpt, and chatgpt answered as follows:
git co
It is git checkout
an abbreviated form of , which needs to be enabled in Git's global configuration or alias configuration. It is used to switch branches or restore working tree files. Once configured, you can use git co
instead git checkout
. For example, you can use git co -b feat/xxx
Mingbin to create a new branch and switch to that branch. By shortening the length of the command, the efficiency can be improved to a certain extent.
configuration process
Execute the command on the console:
git config --global alias.co checkout
This command tells Git to add an alias co to the global configuration (specified by the --global parameter), which represents the checkout command. The global configuration is located in the .gitconfig file in your user's home directory, and can affect all Git repositories of the user on the local machine.
After configuration, the final configuration display form in .gitconfig is as follows: