2

I use number of commits as version of my program (Using hash of commit as version very inconvenient, becouse it not sequential). So I obtain commit number:

git rev-list --count HEAD

For example for current state it reurns 53. Can I do checkout to commit number 35 ? Or obtain hash of commit number 35 ?

Ivan Borshchov
  • 2,629
  • 4
  • 32
  • 59
  • 1
    This sounds like a really bad idea. This will certainly cause issues when you're using multiple branches or when you have multiple people working on the same code base, including local branches, local commits, etc. I suggest you start using something like a manually assigned version number. If you want, you can still add a build number or version hash, or time stamp to differentiate between builds. – nwinkler Feb 23 '15 at 10:37
  • I'd suggest to use incremental builds via CI server (Jenkins or any other). In this case you don't need to do versions manually - just configure the build after every commit. New app build will have new version automatically. – Vitalliuss Feb 23 '15 at 11:05
  • 2
    You can checkout for `HEAD~18`. Where `18 = 53 - 35`. However that won't work with branches as @nwinkler mentioned. It will only use the first parent, ignoring the second. – Sbls Feb 23 '15 at 11:14

0 Answers0