title: How do I safe git information in a file using GNU-make variables
body: <p>I want to save some git information in a textfile, which I want to put in the src folder of my project.</p>
  <p>In case branch Master is checked out, I only want the date of the latest commit. If any other branch is checked out I want the date and the name of the branch like so:</p>
  <p><code>date-branchname</code></p>
  <p>This is my code:</p>
  <pre><code>src/version2.txt:
      DATE=$(shell git log -1 --date=format:&quot;%Y.%m.%d&quot; --format=&quot;%ad&quot;)
      BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
      
  ifeq ($(BRANCH), 'Master')
      $(DATE) &gt; $@
  else
      DATE+='-'
      DATE+=$(BRANCH)
      $(DATE) &gt; $@
      
  endif
  </code></pre>
  <p>I'm new to GNU make and quite confused with its syntax.
  I assume my ifeq/else blocks are working fine, since I checked printing a dummy text to the <code>version.txt</code> file while having the Master or some other branch checked out.
  I also saw my commands to get the date or the branch are ok, since I can put them to the textfile like so:</p>
  <pre class="lang-sh prettyprint-override"><code>git log -1 --date=format:&quot;%Y.%m.%d&quot; --format=&quot;%ad&quot; &gt; $@
  </code></pre>
  <p>Only when I want to use variables, it seems the variable is empty, for example</p>
  <pre><code>$(DATE) &gt; $@ 
  </code></pre>
  <p>seems to print an empty string to the textfile.
  Also, I don't know if my way of creating the DATE-BRANCH output is correct at all.
  I've spent ages trying and would really appreciate some help.
  Thanks</p>