Skip to content

Instantly share code, notes, and snippets.

@turbq
Created August 13, 2024 13:04
Show Gist options
  • Select an option

  • Save turbq/f538d17adf77a831c2c84e8d238f877b to your computer and use it in GitHub Desktop.

Select an option

Save turbq/f538d17adf77a831c2c84e8d238f877b to your computer and use it in GitHub Desktop.
Get commit hash for using in atmel studio (visual studio probably) pre-build event.
rem to use as a command make precentage signs single
git log -n 1 --pretty=format:^
"^
#ifndef GIT_COMMIT_H%%n^
#define GIT_COMMIT_H%%n^
%%n^
static const char* GIT_INFO = \"[%%H, %%d]\r\n\";%%n^
%%n^
#endif%%n^
" > ..\src\gitcommit.h
@turbq
Copy link
Author

turbq commented Aug 13, 2024

CMD one-liner

git log -n 1 --pretty=format:"#define GIT_INFO%nstatic const char* GIT_INFO = "[%H, %d]\r\n";" > output.txt

Powershell one-liner

git log -n 1 --pretty=format:'#define GIT_INFO%nstatic const char* GIT_INFO = "[%H, %d]\r\n";' > output.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment