How to sort git tags by version string order of form rc-X.Y.Z.W?

后端 未结 7 2153
天命终不由人
天命终不由人 2020-11-28 03:44

When I enter a command:

git tag -l

I get such results:

rc-0.9.0.0
rc-0.9.0.1
rc-0.9.0.10
rc-0.9.0.11
rc-0.9.0.12
rc-0.9.0.2         


        
7条回答
  •  自闭症患者
    2020-11-28 04:28

    According to this answer, on platforms which don't support sort -V like Windows and OSX, you can use

    git tag -l | sort -n -t. -k1,1 -k2,2 -k3,3 -k4,4

提交回复
热议问题