How do I find uncommitted changes using Git within MATLAB projects?

15 views (last 30 days)
Background:
I am attempting to switch branches within my MATLAB project that has several submodules and those submodules are then set as references just as is done here.
While attempting to swithch branches in the parent project folder I get the attached error indicating I have uncomitted changes. However, the commit button is grayed out with nothing showing in modified. I have attempted the following steps to debug:
  1. Check all submodules for uncommitted changes. - there are no uncommitted changes in submodules.
  2. Change branches in submodules. - I am able to change branches in each submodule that has multiple branches.
  3. Create a stash in the parent project folder. - No stashes are created but the status bar shows "Completed: Creating stash from modified files."
  4. Create a trivial modificiation to the parent project (add a folder called tst) and then commit. - I still get the same uncommitted changes while attempting to switch.
  5. I have pushed, pulled, and fetched and still have the same error.
This is not the first time this has happened to me. Likely this is an indicaiton of user habits. In the past I have fixed this by removing all related files from my computer and recreating my local repo. This is no longer sustainable.
Question:
How do I find uncommitted changes using Git within MATLAB projects?

Accepted Answer

Tushar
Tushar on 4 Jun 2023
Hi Wesley,
It seems like you are facing issues with uncommitted changes when trying to switch branches in your MATLAB project that contains submodules. Here are a few suggestions you can try to resolve this problem:
  1. Check for Uncommitted Changes: Even though the commit button is grayed out, you can still check for uncommitted changes by running the following command in the MATLAB command window within your parent project folder:
!git status
This will display the status of your project and any uncommitted changes. Make sure there are no modified files or
untracked files listed.
2. Discard Local Changes: If you have made any local modifications within your parent project folder that are not being
recognized by Git, you can try discarding those changes. Use the following command to discard all local modifications:
!git checkout -- .
This will discard all changes made to the tracked files in your project.
3. Update Submodules: It's possible that the submodules within your project have uncommitted changes that are causing
the issue. Make sure to update all submodules to the latest commit on their respective branches. Use the following
command in each submodule directory:
!git checkout <branch-name>
!git pull
Replace <branch-name> with the desired branch name.
4. Reset Submodules: If updating the submodules didn't resolve the issue, you can try resetting them to the latest commit
on their respective branches. Use the following command in each submodule directory:
!git reset --hard HEAD
This will reset the submodule to the latest commit, discarding any local modifications.
5. Clean and Rebuild: If none of the above steps work, you can try cleaning and rebuilding your MATLAB project. Delete
any generated files or folders, such as compiled binaries, temporary files, or cached data. Then, rebuild your project
from scratch.
  2 Comments
Strider
Strider on 4 Jun 2023
Thanks for the answer Tushar.
I actually do not have git configured to run from my Windows command window so your suggestions are not viable for me. I have little lateral movement with Software installs / Environment Variable permissions on my computer. As such, I have been relying on MATLAB's 'batteries included' git integraiton.
Could that be part of the issue?
Tushar
Tushar on 4 Jun 2023
Yes, most probably. Please configure git on your system. And try running the above commands. These may help resolving the issue.

Sign in to comment.

More Answers (1)

Jan Kappen
Jan Kappen on 17 Sep 2024

Categories

Find more on Source Control in Projects in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!