简体   繁体   中英

How do I emit the SHA1 of a git branch using MSBuild

The following git command...

git show -s --pretty=format:%T master

...will emit the SHA1 of the current head of master.

However the following MSBuild task only produces a literal 'T'

<Exec Command="git show -s --pretty=format:%T master" />

What do I need to change, to emit the genuine SHA1?

So apparently the trick is to double escape the % sign.

ie

<Exec Command="git show -s --pretty=format:%25%25T master" />

I'm not really sure why this works though, so I'd appreciate comments on why this might be.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM