When I add a .prj Simulink Project to a Git repository manually (outside MATLAB) and another user tries to pull the Simulink project, the project is empty and the contents are incorrect. Why is it happening?
MATLAB: Does a Git pull (check-out) of .prj Simulink Project from the Git repository gives me an empty project
failgitprojectpullsimulink
Related Solutions
This can be done by using SVN externals:
This will allow you to create a subfolder in your current directory that contains a reference to another SVN repository. You may also choose the specific revision when creating the SVN external.
After creating this subfolder, you can create a project reference to the project inside the created sublfolder.
Alternatively, you may check out the specific revision of the project to-be-referenced, then create a project reference to the checked out copy.
This behaviour is observed when both the local and remote repositories have working directories.
If you create a GIT repository with a working directory you should be able to see your files in it, and commit, push and fetch.
So for example this behaviour can be reproduced with these steps:
- Create a repository, let's call it "ProjectA", add some files, make some commits.
- Clone this to another repository, "ProjectB", by setting ProjectB's "Repository Path" to ProjectA.
ProjectB is initially exactly the same as ProjectA, but pushing and fetching produces inconsistencies between the two.
This workflow of cloning an existing working git repository is not best practice with git, which is why it gives this strange behaviour.
The best practice is to create a "bare" git repository for your remote. This is a repository for keeping a master copy of all the source history, but does not have a working directory.
All working copies of your project should use this bare repository as its remote repository. They all push and fetch from the bare, and any conflicts that occur can be resolved when pushing or fetching from the shared location.
In a bare repository you will not see your files, but a file structure like this:
If you open the ".git" folder in a working repository you will see the same files. These contain all the source control changes and history.
In Simulink Project it is possible to create a bare repository and a working copy at the same time:
1. In the HOME ribbon select New > Simulink Project > From Source Control
2. When setting the repository path, click the "Change..." button.
3. In the "Select A Repository" Window that opens click the + button and select a folder for keeping the bare repository in.
4. Click Retrieve and then "Yes" when it asks if you want to create a new project.
5. Click "Create" to create the project.
This will create a bare repository in the folder selected in step 3, and a working copy of the bare repository wherever you created the simulink project.
If you want to create more working copies of your project, you should set the repository path to be the bare repository. All the working copies will consequently push and fetch changes to/from the bare repository. This is the standard workflow with git.
Best Answer