Is their a way to inject last commit number/branch information into your code files in github? Maybe using some kind of reserved word or token? I'm a little new to advanced source control and git so forgive if I'm not using the right terminology and feel free to rephrase question.
-
what are you actually trying to do? why do you need this? – Ocaj Nires Aug 05 '11 at 15:26
-
1This isn't about github, it's about git. Either git has a way to do keyword expansion or it does not. – bmargulies Aug 05 '11 at 15:28
3 Answers
The answer is yes but it isn't recommended.
https://git.wiki.kernel.org/index.php/GitFaq#Does_git_have_keyword_expansion.3F

- 97,814
- 39
- 186
- 310
See Git FAQ for keyword expansion. The solution is to add an ident entry to .gitattributes about which files should be modified on checkin/checkout:
When the attribute ident is set for a path, git replaces $Id$ in the blob object with $Id:, followed by the 40-character hexadecimal blob object name, followed by a dollar sign $ upon checkout. Any byte sequence that begins with $Id: and ends with $ in the worktree file is replaced with $Id$ upon check-in.

- 60
- 5
-
but is there are more meaningful (to the end user) thing that resembles a version # than $id$ – BuddyJoe Aug 08 '11 at 20:57
It might be possible through your build system. In your build scripts you can execute git commands to get the necessary information and then pass these as macros in your code.

- 5,353
- 3
- 30
- 34