I am working with git version control and would like to use the following function to commit my changes:
function gitCommit( str ) currDirectory = pwd; cd(myScriptDirectory); % Add all files and changes to git
!git add * % Commit everything to repository with a message
!git commit -m str cd(currDirectory);end
Then, regardless of where I'm working, I could simply type:
gitCommit('This is my commit log');
and it will commit all of the modifications I've made to a script in myScriptDirectory to the local repository while also recording the log 'This is my commit log', negating the need for me to enter it later into a pop-up window. The problem is that, if I do this, then the log file will always read 'str' and not 'This is my commit log', as this code is incapable of actually taking the content of the str variable and passing that to the !git command. Instead, it always just passes 'str'. I have no idea how to accomplish this. Any tips?
Best Answer