Using GitHub with MATLAB R2014b

As you know, we have a control source in MATLAB R2014b . I want to use GitHub with Matlab R2014b. MATLAB has a guide for Git . Instructions for third-party version control tools:

If you use third-party version control tools, you must register your MATLAB and Simulinkยฎ file extensions, such as .mat, .mdl and .slx as binary formats. If you do not register extensions, these tools can damage your files when you send them, changing the end of the character string, expand tokens, replace keywords or try automerge. Corruption can occur if you use source control tools outside MATLAB or if you try to send files with MATLAB without first registering file formats.

What should I do for this? In MATLAB we need to set the "repository" and the "sandbox". How can I install them on GitHub (in particular, the sandbox)? Should I create a repository with MATLAB or GitHub? How to associate a repository with a second?

Is the "Sandbox" in MATLAB the same as the "Clone" in GitHub?

+7
git github matlab
source share
2 answers

This image shows the Git workflow in MATLAB.

Git workflow for MATLAB

As you can see, you will be working in your local directory, which is your Sandbox. From there, you can make changes to your local repository. Then they can be transferred to a remote repository, for example. Github

You can select clone remote git repository or create a new one .

I recommend that you create a new repository in GitHub and then use the clone link to create a local repository from MATLAB. This will clone the empty repository into your working directory. This local copy is called the sandbox. You can start working with these files and modify them. Once you have reached a certain milestone, you can commit the changes to your local repository. This will be ahead of the remote repository (GitHub). You can then drag these commits to the remote repository (or extract other commits that others have added to the remote repository).

After you have added the repository, you first need to register your binaries; Create a gitattributes file in your repository and add the following content;

 *.mat -crlf -diff -merge *.p -crlf -diff -merge *.slx -crlf -diff -merge *.mdl -crlf -diff -merge 

These lines indicate no attempt to automatically feed lines, differences, and merge attempts for these file types.

You can also check other file types you use, which you also need to register as binary files in order to avoid corruption during registration. Check files such as .mdlp, .slxp, MEX files (.mexa64, .mexmaci64, .mexw32, .mexw64) .xlsx, .jpg, .pdf, .docx, etc. Add a line to the attributes file for each file type that you need;

 *.mdlp -crlf -diff -merge *.slxp -crlf -diff -merge *.sldd -crlf -diff -merge *.mexa64 -crlf -diff -merge *.mexw32 -crlf -diff -merge *.mexw64 -crlf -diff -merge *.mexmaci64 -crlf -diff -merge *.xlsx -crlf -diff -merge *.docx -crlf -diff -merge *.pdf -crlf -diff -merge *.jpg -crlf -diff -merge *.png -crlf -diff -merge 

You can find more information here: http://www.mathworks.nl/help/matlab/matlab_prog/set-up-git-source-control.html

After that you can mark files for addition and commit in your local repository. If you want, you can also click and extract to the remote repository.

Note that if you want to merge branches, you will need to install the Git command line client if you do not already have one.

+4
source share

Explicitly specify these files as binary in the .gitattributes file:

.gitattributes

 # MATLAB/Simulink binary formats *.mat binary *.mdl binary *.slx binary # etc.. 
+2
source share

All Articles