The graphical part of your model also has to be stored somewhere, and the place Modelica uses are so called annotations. Every model, instance of a model and also every connection has such annotations. The graphics do not influence the "pyhsical" behavior, but they are still important for end user convenience.
Now, if you edit some icon or connection (or, anything else) from the GUI, this change will be reflected in the code. And once you click the save button, the file will be written to disk and git will notice that the code has changed. Some of these changes might be on purpose (some people invest a lot of time in nice looking connections), while other changes might not be important. There is absolutely no way how a version control system can decide what you consider relevant, that decision is up to you. You can always decide NOT to save your changes (in Dymola, choose the Save None
button).
In addition to the changes that you are responsible for, your tool (e.g. Dymola) might try to be smart and do some auto-formatting. There are users that consider Dymolas behavior too intrusive (e.g. breaking lines, inserting whitespace, adding irrelevant annotations, moving comments around). Sadly, there is not much you can do here, except of course stopping to use Dymola as an editor (and instead only use it as a simulation tool), or you can use cleanup tool like ttws (trim-trailing-white-space). As far as I know, Dymola does not move around your icons, so the example you showed was not introdced by Dymola.
Now, second part of your question. If for some reason you have clicked the save button, git (and any other good version control system) allows you to revert your changes, or part of your changes, before commiting (or after commiting, but then things get more complicated). Also, you do not have to push all your commits to the central repository. The exact workflow will depend on which git client you use and whether you use a graphical user interface or the command line. Which one do you use?
Below is a screenshot of the GitExtensions commit dialog (this image is the main reason for writing an answer instead of a comment):
- On the left top, you see all files where git has noticed a change,
here you can revert whole files.
- On the left bottom, you see the staging area. Only the files in the staging area will be part your commit.
- On the right top, you see the diff and the context menu that allows to reset single lines of code.
- On the right bottom, you would type your commit message.
There are many tutorials and books available on how to use git, you probably want to read these, as well as the manual for the git client of your choice. Or, you simply do not click the save button when there is nothing you want to save.
git reset
, e.g. here. – Chatterergit stash
to temporarily move changes away. – Chatterergit stash
meant for temporarily storing changes that you want to keep working on later? If you accidentialy introduce changes while showing something to a colleague, the easiest solution would be to just not save these changes!? Or if it is already too late for that, revert/reset them. – Denotation