Skip to main content
CDyer.1
Associate III
October 14, 2024
Question

How to use GIT branching while using STM32cubeIDE?

  • October 14, 2024
  • 7 replies
  • 3872 views

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.

7 replies

Radosław
Associate II
October 14, 2024

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

 

Explorer
October 14, 2024

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

Radosław
Associate II
October 14, 2024

Option B is NOT recomended by eclipse.

PS git repositories should be outside od workingspace.

Explorer
October 14, 2024

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.

Karl Yamashita
Principal
October 14, 2024

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

 

 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
Explorer
October 14, 2024

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

Radosław
Associate II
October 14, 2024

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
Principal
October 14, 2024

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.

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
CDyer.1
CDyer.1Author
Associate III
October 15, 2024

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?

Radosław
Associate II
October 15, 2024

If You whant to have 2 copy o same git repo to work with just  create TWO workspeces.