0

I have a project in php with the use of GIT and there is a file called "version" with inside "1". I want that when i commit the number is incremented. I am using the git hook feature with this script:

num=$(cat version) num=$(expr 0$num + 1) echo $num > version git add -u version

All work fine except that when i check on the ide (phpstorm), the file stay "blue" (not syncronized) so if i click commit i see the file "version" modified.

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
Atomico
  • 453
  • 1
  • 6
  • 26
  • do you add 'version' in versionning git system ? – miltone Jan 21 '16 at 22:20
  • the problem is that i need a remote version... i upload my php project on the host and i want know on the remote host which version i am using... i'm trying to do an automatic system instead edit manually a file version.txt – Atomico Jan 22 '16 at 11:06

1 Answers1

1
  1. You must to ignore this file and don't have it in repo
  2. You reinvented the wheel and gonna duplicate a) already existing inside Git b) always and automatically correct information

In short: don't do it at all, do not solve the problem in so wrong way

Answers in How to get the git commit count? and this answer in what is the git equivalent for revision number? and a lot of questions about git describe (variations of second attempt) will give you a lot of ideas and methods getting changeset-count on the fly in pre-build step.

While incremental counter in DAG is, from my POV, is bad and poor concept, git rev-list --count <revision> or git rev-list --all --count is the most correct method for getting changesets counter

Community
  • 1
  • 1
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110