diff --git a/build/simulink_codegen/writegitinfoheader.m b/build/simulink_codegen/writegitinfoheader.m
index 9dc392c906997835824a6009a9a696c79fd69b3b..abcb76d2d9f986422e80a4251e05e08ca91ba7b4 100644
--- a/build/simulink_codegen/writegitinfoheader.m
+++ b/build/simulink_codegen/writegitinfoheader.m
@@ -1,20 +1,39 @@
 function writegitinfoheader()
-   % max description length
+   % max code description string length
    maxdesclen=1024;
 
+   % scd expcode info retrieval
+   try
+       scd=Simulink.data.evalinGlobal('tcv','scd');
+       expcode = scd.expcode;
+       expcodeset=true;
+   catch ME
+       warning('No configured expcode found, code description string will not have this info.');
+       expcodeset=false;
+   end
+  
+   % Git checks 
+   
+   % 1) check repo cleanlyness
+   % TODO: check that the output of 'git status -procelain' is empty
+   [~,result] = system('git status --porcelain');
+   if ~isempty(result)
+       error('the working copy is not clean, please commit changes first.');
+   end
+   
+   % 2) check local and remote hash are matching (in synch working copy)
+   [~,localhash]  = system('git rev-parse @');
+   [~,remotehash] = system('git rev-parse @{u}');
+   if ~strcmp(localhash, remotehash)
+       error('the working copy is not in sync with its origin, please push first.');
+   end
+   
    % first we get TCV current shot number, to be used for tagging
    mdsconnect('tcvdata');
    curshot=mdsvalue('current_shot("tcv_shot")');
    
    % then we try to tag the current rtccode repo 
-   
-   % TODO: check git repo cleanlyness, see script gittaglac
-   % TODO: clean build folders first, the generated .h is not
-   % checked for changes by the standard generated makefile
-   % it is enough to remove the primary model build folder
-   % (i.e. rm -rf SCD_rtccode_xx_xx*) so that submodels builds
-   % can be kept
-   
+      
    tagname = ['builds/TCV' num2str(curshot)];
    str=sprintf('Going to try this git tag: %s [(Y)es/(N)o/A(p)pend]?',tagname);
    answ=input(str,'s'); 
@@ -51,8 +70,15 @@ function writegitinfoheader()
       fprintf('could not retrieve tag info, git error: \n%s\n', result);
       return
    end
-
+   
    descstr=result;
+
+   if expcodeset
+       descstr = ['EXPCODE: ' num2str(expcode) ' ' descstr];
+   else
+       descstr = ['EXPCODE: n/a ' descstr];
+   end
+   
    if numel(descstr)>maxdesclen
        descstr=descstr(1:numel(descstr));
        fprintf('WARNING: code description string truncated!\n');
@@ -81,7 +107,10 @@ function writegitinfoheader()
    
    fclose(fd);
    
-  
-   
+   % TODO: clean build folders first, the generated .h is not
+   % checked for changes by the standard generated makefile
+   % it is enough to remove the primary model build folder
+   % (i.e. rm -rf SCD_rtccode_xx_xx*) so that submodels builds
+   % can be kept 
    
 end
\ No newline at end of file