0

I'm working on a game project in Uninty with some friends, and since we're going to make each one his own branches i would like to include in the project some of the versioning info, e.g. to get track of the current build beeing tested, so i've tought to the current branch and commit index.

When i say "include in the project" i mean to display those info somwhere in the ui during gameplay. I would like to do so to avoid using "custom version number" like ver.0.1.2 etc, because those versioning number are totally arbitrary and must be manually updated during development, while branches and commit are indipendent and automatic.

I'm currently working with SourceTree, so when i say "comomit index" i mean the short descriptor displayed in SourceTree under the Commit column, like in linked figure. I've looked into the .git folder but i couldn't find the info I need.

Mine could not be the best idea ever, so i'm open to suggestion to get a unique identifier for the current build.

Anyone can help?

p.s.: i think my question is independent from the repository, the versioning software and the project itself, i'm not looking for a better versioning software or custom Unity solution.

fudo
  • 2,254
  • 4
  • 22
  • 44

1 Answers1

1

Get the last tag in the branch: git describe --abbrev=0 --tags

Get the last commit's abbreviated id: git log -1 --format=%h; full commit id: git log -1 --format=%H.

Get the last commit's subject (first line): git log -1 --format=%s.

See git help log for the full list of available placeholders.

phd
  • 82,685
  • 13
  • 120
  • 165
  • Probably it's my fault, i think i still missing somenthing, but i'm running the firs command from cli inside my project folder (not insite .git folder) and get an error: fatal: No names found, cannot describe anything. – fudo Jun 12 '17 at 09:50
  • git gets info from .git, of course. I.e. you have to run these commands inside a worktree or point git to the .git dir using `GIT_DIR` env var or `--git-dir` command line option. – phd Jun 12 '17 at 14:20