Git For MATLAB: Difference between revisions

From Cheaha
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 1: Line 1:
MATLAB on Cheaha has been configured to work with Git.
MATLAB on Cheaha has been configured to work with Git.


=='''Option 1: Cloning a Git Repository into MATLAB'''==
=='''Cloning a Git Repository into MATLAB'''==
== Create a clean folder to use with Git ==
== Create a clean folder to use with Git ==
To start out with, MATLAB's Git requires an empty folder. Currently this is just an empty folder with no source control (a regular MATLAB folder).
To start out with, MATLAB's Git requires an empty folder. Currently this is just an empty folder with no source control (a regular MATLAB folder).
Line 22: Line 22:


Once this dialog has been filled in appropriately, clicking the "Retrieve" button will initialize the repository and checkout the current revision into the selected folder
Once this dialog has been filled in appropriately, clicking the "Retrieve" button will initialize the repository and checkout the current revision into the selected folder
Upon re-inspection of the file browser, it should have now changed to match what is currently in the Git repository that was cloned.
[[File: MatlabGitStatusUponInitialClone.png |200px|center|initializing source control]]
The file browser also now has a "Git" column, which displays the current Git status of each file in the folder.
* A green circle implies the file is up to date
* An empty circle implies the file is currently untracked
* A dot implies the file is ignored by the repository (generally due to rules placed in a .gitignore file)
* A blue square implies the file has been modified since the last commit
* A plus sign implies the file is a new file and has been staged for adding to the repository
Once you have finished your changes, don't forget to "Push" your folder's state back to the repository.
[[File: MatlabPushChangesBackToGitRepo.png |450px|center|initializing source control]]
WARNING: MATLAB does not give any indication whether the current repository in the working directory is up to date with the remote Git repository. It is a good practice to perform a "Pull" prior to doing any work within your working directory, and "Push" after any "Commit."
==Using a working directory previously initialized to Git==
If you navigate within MATLAB to a working directory initialized to a Git repository using other means, MATLAB will still recognize the folder as source controlled by Git. All normal Git functions will be available through the MATLAB contextual menu, and the icons in the file browser should show the correct Git status.
==Troubleshooting==
MATLAB supports most Git actions as shown in the context menu. If any functions are not working as expected, the "system" command can be used in the MATLAB terminal to simply use the normal Git command line tools.
We are investigating some intermittent behavior issues with inputting comments upon committing within MATLAB on Cheaha. If you experience this issue, please let us know. Feel free to use the Git command line tools in order to workaround the issue.

Latest revision as of 16:25, 12 July 2018

MATLAB on Cheaha has been configured to work with Git.

Cloning a Git Repository into MATLAB

Create a clean folder to use with Git

To start out with, MATLAB's Git requires an empty folder. Currently this is just an empty folder with no source control (a regular MATLAB folder).

start out with a clean folder

If you have no empty folder, create one, as MATLAB's Git will give an error if there are any files in the folder.

Clone a Git Repository using MATLAB

Right click in the file browser to bring up the context menu. Navigate to and select Source Control->Manage Files

initializing source control

The "Manage Files using Source Control" interface will pop up. Select ""Git"" for your ""Source Control Integration"" option. Under ""Repository Path"" you place the URL of the repository you are going to clone into your empty directory. ""Sandbox"" should be filled in with the current directory. Ideally this is the directory in which you wish to place the cloned repository.

initializing source control

In this screenshot a sample GitLab Repository URL is pasted into the ""Repository Path"" text box. If you click "Change" on the same line, an additional window will appear where you can also validate the link prior to attempting to clone the repository.

Once this dialog has been filled in appropriately, clicking the "Retrieve" button will initialize the repository and checkout the current revision into the selected folder

Upon re-inspection of the file browser, it should have now changed to match what is currently in the Git repository that was cloned.

initializing source control

The file browser also now has a "Git" column, which displays the current Git status of each file in the folder.

  • A green circle implies the file is up to date
  • An empty circle implies the file is currently untracked
  • A dot implies the file is ignored by the repository (generally due to rules placed in a .gitignore file)
  • A blue square implies the file has been modified since the last commit
  • A plus sign implies the file is a new file and has been staged for adding to the repository

Once you have finished your changes, don't forget to "Push" your folder's state back to the repository.

initializing source control

WARNING: MATLAB does not give any indication whether the current repository in the working directory is up to date with the remote Git repository. It is a good practice to perform a "Pull" prior to doing any work within your working directory, and "Push" after any "Commit."

Using a working directory previously initialized to Git

If you navigate within MATLAB to a working directory initialized to a Git repository using other means, MATLAB will still recognize the folder as source controlled by Git. All normal Git functions will be available through the MATLAB contextual menu, and the icons in the file browser should show the correct Git status.

Troubleshooting

MATLAB supports most Git actions as shown in the context menu. If any functions are not working as expected, the "system" command can be used in the MATLAB terminal to simply use the normal Git command line tools.

We are investigating some intermittent behavior issues with inputting comments upon committing within MATLAB on Cheaha. If you experience this issue, please let us know. Feel free to use the Git command line tools in order to workaround the issue.