How to switch between two workspace

Hi,
I build a new catkin workspace B, is there a way to go back to the old catkin workspace A.
Thank you for reading this post.

Hi @zhangmingcheng28,

Could you please provide more information so we can help you better?

  • are you working locally or on the Academy environment?
  • What is the full path of both workspace A and workspace B?

Having said that, the only critical part of your workspace is the src subfolder, so if you want to keep your project files you need to move this folder to a new workspace:

  • Let’s say your old workspace is ~/catkin_ws1 and the new one is ~/catkin_ws2.
  • You can move back to the old workspace thus:
# move your source from the new to the old
cp -rf ~/catkin_ws2/src ~/catkin_ws1/src

# rebuild the old workspace
cd ~/catkin_ws1
rm -rf build devel
catkin_make

# only if you want to remove the new workspace
rm -rf ~/catkin_ws2

Hi,
Thank you for the reply, I am working on local environment.
# Workspace A path is
home/abc/catkin_ws
# Workspace B path is
home/abc/catkin_ws2
And thank you for the method provided. and re-build the old workspace, will that cause the dependencies in the old workspace to be cleared out?
Thank you for reading this post.

Hi @zhangmingcheng28,

Thanks for your response. Everything necessary for your project is (and should be) in the src subfolder and they are regenerated again when you run catkin_make. So you don’t need to bother about losing anything as long as you keep the src folder safe.

However, once you have merged your src folders, I suggest you delete the other workspace that you don’t need so that you don’t create conflicting packages.

Hi,
Thank you very much for the help.

1 Like