フィルターのクリア

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 Center および File ExchangeSource Control Integration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by