How to set aliases in the Git Bash for Windows?

后端 未结 8 1686
渐次进展
渐次进展 2021-01-29 19:34

How to alias command in Git Bash for Windows downloaded from git-scm.com ?

I mean Bash commands not Git.

(windows7)


Edit:

Writing aliases i

相关标签:
8条回答
  • 2021-01-29 20:18

    You can add it manually in the .gitconfig file

    [alias]
        cm = "commit -m"
    

    Or using the script:

    git config --global alias.cm "commit -m"
    

    Here is a screenshot of the .gitconfig

    0 讨论(0)
  • 2021-01-29 20:29

    There is two easy way to set the alias.

    1. Using Bash
    2. Updating .gitconfig file

    Using Bash

    Open bash terminal and type git command. For instance:

    $ git config --global alias.a add
    $ git config --global alias.aa 'add .'
    $ git config --global alias.cm 'commit -m'
    $ git config --global alias.s status
    ---
    ---
    

    It will eventually add those aliases on .gitconfig file.

    Updating .gitconfig file

    Open .gitconfig file located at 'C:\Users\username\.gitconfig' in Windows environment. Then add following lines:

    [alias]  
    a = add  
    aa = add . 
    cm = commit -m 
    gau = add --update 
    au = add --update
    b = branch
    ---
    ---
    
    0 讨论(0)
提交回复
热议问题