How do I determine what branch/tag I have checked out in git?

前端 未结 4 1929
感动是毒
感动是毒 2021-01-14 12:01

I clone my source using git clone https://gerrit.wikimedia.org/r/p/mediawiki/core.git w/. Then I specify a specific branch/tag by doing git checkout

4条回答
  •  孤街浪徒
    2021-01-14 12:34

    If you use the bash shell, you can use __git_ps1 in your bash prompt to show this, for example:

    [me@myhost:~/code/myproject] (master)$ ls
    

    Download git-completion.bash to ~/.git-completion.bash

    Then in your ~/.bashrc file, add

    source ~/.git-completion.bash
    

    Then set your PS1 value to something including $(__git_ps1 "(%s)"), something like:

    PS1="[\u@\h:\w]\$(__git_ps1)\\$ "
    

提交回复
热议问题