cancel
Showing results for 
Search instead for 
Did you mean: 

How to use GIT branching while using STM32cubeIDE?

CDyer.1
Senior

Hi all,

I have a project that has been developed within STM32CubeIDE. I also have a github repository associated with the project. What I now want to do is branch the project to work on some other features. I may want to have two separate projects in  the future, one with the original features and one with the new features. I may also want to simply merge the branch at a later date and have only the project with the new features added. How can I do this while working within STM32CubeIDE? Obviously CubeIDE doesn't know that I've started a new branch, so any changes I make will be made to the same project within CubeIDE. Do I need to make a separate project within CubeIDE? How can I associate that with the new branch? I could simply copy the project within CubeIDE and make a new repository for the new project, but I'd like to keep everything within the same repository and just branch - the git intended. Any help with this would be great.

10 REPLIES 10
Radosław
Senior II

You can use git in STMCubeIDE, It's eclipse based and  all plugin will work normally.

 

schnedan
Associate II

I dont know if it is the best solution but this is what I do:

A: include project files in Git repository

B: include the workspace in the Git repository or better: as 2nd git repository (you may bind it as subproject if you like or manage by hand...

C: when change branches close the IDE, commit project & workspace, switch branch, reopen the IDE

 

This ensures things are consistent. Of course if you add files or change project settings you need to copy these changes to all branches as needed.

 

PS: I use external git Gui tools and a bunch of scripts - not the eclipse plugin

Option B is NOT recomended by eclipse.

PS git repositories should be outside od workingspace.

Karl Yamashita
Lead III

You can either use a plugin in STM32CubeIDE by searching in the Eclipse Marketplace under the Help menu, or you can use a 3rd party Git interface. I like using TortoiseGit which you can use on other types of folders that are not an STM32 project. It has a lot of features

KarlYamashita_0-1728919302326.png

 

 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

Well, I have encountered a screwed up workspace with eclipse / stm32cubeide several times now, and the best solution to fix it and get a working setup again was to include the workspace in the version control. Its not elegant, but at least it mitigates the problem.

 

but I recommand to put it in a own repository as it has anonther commit frequency as the normal project.

after testing a lot Git Gui's I can recommand gitkraken or gittyup as second best

Radosław
Senior II

Again, including workspace in git repo i very bad idea,

Eclipse (STMCubeIDE) have very good GUI for git, many people seys the best, and use quite often eclipse only for git.

 

Karl Yamashita
Lead III

To make it clear, you can create a repository for each project. And each repository can be part of the Eclipse workspace. You can clone/branch individual projects.

 

However, if you make the Eclipse workspace a repository, when you want to clone only one project, you have no option but to clone all the projects from inside the workspace.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
CDyer.1
Senior

I think my understanding of how the IDE and Git interact (or don't) was a bit flawed. I can branch the project off within Git, do my changes within the IDE and then if I want to go back to the master project I can just do that in Git and then reload the IDE. I was getting stuck on the idea of having two separate projects to work from within the IDE, which I guess isn't really the point?