If on Windows, first get https://msysgit.github.io/. Default settings on the installer should be fine. Make sure you select Git BASH instead of Git GUI or Shell Integration.
Once you open up MATLAB, add this project from GitHub using the following menu:
Then, enter the following into the dialog:
When adding files and changes to Git, the current setup will require you to enter your GitHub username and password every time you want to push those changes to the internet. To avoid this, we will follow these steps:
- Open Git BASH. This was installed in the first step.
- Run the following command, replacing the email address with the one used for your GitHub account:
ssh-keygen -t rsa -m PEM -b 4096 -C "email_address@example.com"
- Enable the ssh-agent using the following commands:
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
- Next, print out your ssh key using the following command:
cat ~/.ssh/id_rsa.pub
- Copy the printed key to the clipboard, then head over to github.com. Navigate to
Settings > SSH and GPG keys > New SSH Key
and paste the key into the key box. The title can be whatever you want. - You can verify that this worked using the following command:
ssh -T git@github.com
- Go to the directory where you created the Simulink project using the following command and your directory:
cd /path/to/the/oru-nasa-eap/directory
- Execute the following command:
git remote set-url origin git@github.com:bbraunj/oru-nasa-eap.git
- Check that the following command:
git remote -v
Produces the following output:
origin git@github.com:bbraunj/oru-nasa-eap.git (fetch)
origin git@github.com:bbraunj/oru-nasa-eap.git (push)
- If MATLAB is open, close it and open it back up for changes to take effect.
Now you should be able to push changes to the server without typing in your username and password every time.
- Let's say you create a new Simulink model named
Hello_World.slx
from the Project tab in MATLAB as shown below:
- You make some changes and feel ready to save those changes to the server. The first step is to make add any files that you created, as shown in the figure below.
- Next, you commit these files. Committing in Git is like a savepoint that contains your files exactly as they are in this point of time. To do this, press the button shown in the following figure and enter a concise message of what changes/additions you made. This is very helpful for tracking what changes were made over time.
- Once you click submit, these changes are saved in the local copy of the Git repository. Next, you need to push these to GitHub. This is simply done by clicking the button shown below:
Your changes should now be on GitHub!
If your local copy of the Git repository is behind the GitHub copy, you will want to pull those changes down to your computer. To do this, simply click the button in the source control menu.
Let's say you and someone else both have a certain copy of oru-nasa-eap
on your computers. The other person makes changes to a file and pushes those to the server. If you make changes to the same file and try to pull changes from the server, you will encounter the following error message:
In this case, contact @bbraunj and he can help you figure this out.