필터 지우기
필터 지우기

Commiting and pushing files from MATLAB to Github using MATLAB script

조회 수: 6 (최근 30일)
Manoj
Manoj 2023년 2월 7일
편집: Manoj 2023년 2월 8일
Hello All,
I'd like to push a excel file to my github repository(external) that's generated after running a MATLAB script.
I was able to run these below MATLAB commands but not sure how to connect and push to an external github repository
[~, userNameOutput] = system('git config --global user.name');
[~, branchNameOutput] = system('git name-rev --name-only HEAD');
[~, gitCommitSHA] = system('git rev-parse HEAD');
I'm looking something like this Ocktokit library where I can provide auth and commit and push the files using git commands

채택된 답변

Luca Ferro
Luca Ferro 2023년 2월 7일
편집: Luca Ferro 2023년 2월 7일
assuming you already cloned your repository in a local directory and already made the checkout of the branches, just move to that directory, add the file, commit your changes and push:
(1)
system('git add <fileName.extension>');
system('git commit -m "<message-to-Commit>"');
system('git push');
if the assumption is not correct, i guess that you have a local branch with no upstream. In this case you can either:
system('git branch --set-upstream-to <remote-branch>') %then add,commit,push
or change the push command in (1) with:
system('git push -u origin local-branch') %git remote -v to find your remotes, the default one is origin usually
Note:
if in (1) you want to programmatically set the name of the excel file refer to this question to get the name of the latest generated file. Then strcat the add command with the name.
Same goes for the commit, just strcat the command and the message together.
  댓글 수: 7
Luca Ferro
Luca Ferro 2023년 2월 8일
편집: Luca Ferro 2023년 2월 8일
what you have put in system() is not a string, you need square brackets [ ]:
[~, gitAdd]= system(['git add' ' ' varargin{1}.filename_PD]);
Manoj
Manoj 2023년 2월 8일
편집: Manoj 2023년 2월 8일
Also please let me know if you can help on this qstn
https://in.mathworks.com/matlabcentral/answers/1893275-setting-up-of-port-forwarding-to-postgresql-from-matlab?s_tid=srchtitle

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Source Control Integration에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by