What is the ideal GIT setup for ROS2 and MicroROS for hobbyist/newbie

Hi All, what is the best way to organize a git repo for ROS dev. I tried to look around to some repos to see how things are set up but haven’t found a canonical example. My requirements are that I need to support both ROS2 and MicroROS. My idea of an ideal setup (with some suggestions from chatgpt) looks something like this. Does this look right?

~/ros_ws/ # :small_blue_diamond: Git repository root
β”œβ”€β”€ .git/ # :white_check_mark: Git tracking everything inside ros_ws/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ ros2_ws/ # Main ROS 2 workspace (robot code)
β”‚ β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”‚ β”œβ”€β”€ my_robot_control/
β”‚ β”‚ β”‚ β”œβ”€β”€ my_robot_bringup/
β”‚ β”‚ β”‚ β”œβ”€β”€ my_robot_msgs/
β”‚ β”‚ β”‚ β”œβ”€β”€ micro_ros_firmware/
β”‚ β”‚ β”œβ”€β”€ install/ # :cross_mark: Should be in .gitignore
β”‚ β”‚ β”œβ”€β”€ build/ # :cross_mark: Should be in .gitignore
β”‚ β”‚ β”œβ”€β”€ log/ # :cross_mark: Should be in .gitignore
β”‚ β”œβ”€β”€ micro_ros_agent/ # Micro-ROS agent workspace
β”‚ β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”œβ”€β”€ install/ # :cross_mark: Should be in .gitignore
β”‚ β”‚ β”œβ”€β”€ build/ # :cross_mark: Should be in .gitignore
β”‚ β”‚ β”œβ”€β”€ log/ # :cross_mark: Should be in .gitignore
β”œβ”€β”€ install/ # :cross_mark: Should be in .gitignore
β”œβ”€β”€ build/ # :cross_mark: Should be in .gitignore
β”œβ”€β”€ log/ # :cross_mark: Should be in .gitignore
β”œβ”€β”€ .gitignore # :white_check_mark: Contains ignored folders

Feel free to link to other threads/ or repos

You should not put an entire workspace into Git. Look at some of the repositories in these GitHub organisations for good references:

If your repository contains a single package, then it’s usually just contained at the repository root. If there are multiple packages in a repository, then usually each is a sub-directory (such as the navigation2 repository).

2 Likes

Yes, I think putting all together in one package is a bad idea, The best practice that I use in my day-to-day routine is that every package should be a separate git repo. You can easily manage them from any third party tools like from VS Code or any other tool.