ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
10

How to correctly use git with ROS

asked 2011-06-06 22:11:49 -0500

Catotaku gravatar image

updated 2014-04-20 14:09:22 -0500

ngrennan gravatar image

Hi all!

We are beginning building a stack in ros. And we want to use git as our version control system. But we find a lot of problems with conflicted files created by ROS when we build the packages.

To solve this kind of problems you have done a big .gitignore file ? Or do something to build the project outsite ?

Thanks for all your answers,

Arnau

edit retag flag offensive close merge delete

Comments

Good question !

Arkapravo gravatar image Arkapravo  ( 2012-11-20 21:41:57 -0500 )edit

6 Answers

Sort by » oldest newest most voted
8

answered 2011-06-08 22:15:20 -0500

In our repository, we have a .gitignore file with the following contents:

.cproject
.project
.pydevproject
cmake_install.cmake
build/
bin/
lib/
msg_gen/
srv_gen/

(The first three lines are only relevant if you are using Eclipse.) By placing this file in the top-level directory of the repository, git will ignore all those files/folders even in all subdirectories.

This way, I only need a separate .gitignore file in a package directory to catch some special cases. One not-so-special "special case" is when you have an action definition (e.g., JointMovement in the package katana). In that case, I have the following .gitignore:

msg/JointMovementActionFeedback.msg
msg/JointMovementActionGoal.msg
msg/JointMovementAction.msg
msg/JointMovementActionResult.msg
msg/JointMovementFeedback.msg
msg/JointMovementGoal.msg
msg/JointMovementResult.msg
src/katana/
msg/lisp/

Unfortunately, I have not found a decent way yet to include these patterns into the global .gitignore.

edit flag offensive delete link more

Comments

1
I think the msg/lisp is not needed anymore, at least for diamondback. Roslisp generates its messages into msg_gen now.
Lorenz gravatar image Lorenz  ( 2011-06-08 23:35:41 -0500 )edit

Would the following work for actionlib-generated msgs in package FOO?

AHornung gravatar image AHornung  ( 2013-07-29 22:53:30 -0500 )edit

FOO/msg/*Action.msg FOO/msg/*Feedback.msg FOO/msg/*Goal.msg FOO/msg/*Result.msg

AHornung gravatar image AHornung  ( 2013-07-29 22:53:52 -0500 )edit

(replace spaces with line breaks)

AHornung gravatar image AHornung  ( 2013-07-29 22:54:13 -0500 )edit

Yes, that works. Or borrowing from @"felix k"'s answer, you can also put `*/msg/*Action.msg` etc. into the parent directory. Just tried it [here](https://github.com/uos/katana_driver/commit/838af6197ea20ee16e90b815753a6058dcba0b6a). NB: you can put line breaks into comments using shift-enter. :-)

Martin Günther gravatar image Martin Günther  ( 2013-07-29 23:50:41 -0500 )edit

Ooops. Seems like all the fancy markdown (and shift-enter trick) doesn't work any more in comments. My bad.

Martin Günther gravatar image Martin Günther  ( 2013-07-29 23:51:35 -0500 )edit
8

answered 2011-06-07 02:10:47 -0500

Lorenz gravatar image

We are using gut for most of our stacks. A common gitignore file contains the following entries:

build
bin
lib
msg_gen
srv_gen

You might also want to add generated python files that are placed in src/<your_package> for each package.

edit flag offensive delete link more
4

answered 2012-05-07 00:06:17 -0500

felix k gravatar image

updated 2013-07-09 00:40:01 -0500

I like Martins list and would like to add hidden backups and compiled python files, as I put pythons in src/ rather than bin/ most times.

*~
*.pyc

To ignore headers generated into <package>/src/<package>/.../ you can either put this in the package's .gitignore:

src/*/cfg
src/*/msg
src/*/srv

or this in the parent folder's .gitignore:

*/src/*/cfg
*/src/*/msg
*/src/*/srv

Note that one level of stars denotes the parent folder, independent of that one being your repo base or metapackage folder.

This does not yet ignore <package>/src/<package>/__init__.py, for which I suggest an specific entry in each package where needed.

edit flag offensive delete link more
3

answered 2011-06-07 03:54:49 -0500

A good rule of thumb is to do a make clean on your package before you check it in. Anything leftover after make clean is usually safe to include in a git repo.

edit flag offensive delete link more
1

answered 2012-11-19 08:39:11 -0500

Pascal gravatar image

To hide the files generated by dynamic reconfigure we also have this lines in our .gitignore:

*.cfgc
__init__.py
src/*/cfg
cfg/cpp
edit flag offensive delete link more

Comments

3

All good additions, but the __init__.py is a little too general (you do want to check in some files with that name, only not those generated by dynamic reconfigure).

Martin Günther gravatar image Martin Günther  ( 2012-11-22 20:27:56 -0500 )edit

The cfg/cpp entry doesn't work for me. I've started a StackOverflow question about it: http://stackoverflow.com/questions/25...

Neil Traft gravatar image Neil Traft  ( 2014-08-12 19:52:20 -0500 )edit
0

answered 2011-06-06 23:30:03 -0500

dornhege gravatar image

What do you mean by conflicted files. I'm not using git, but if you are referrring to unversioned files, there should not be many. Usually it is the build/ directory that should be ignored, maybe also lib/ and bin/. Maybe you commited the build/ directory and are now getting a lot of conflicts there. You can leave that out of the repository.

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2011-06-06 22:11:49 -0500

Seen: 6,699 times

Last updated: Jul 09 '13