I'm really struggling to understand git, so here's a tighter rephrasing of a previous question I had asked. I'm going to explain a hypothetical scenario, detailing what I think happens when you download some code using git and install it on a machine, and hopefully somebody can tell me which part I am incorrect about!I run git clone git://github.com/foo/foo.gitThis creates a local directory foo, and downloads the source code and git dataThis source code effectively contains all the versions of the software: source files, header file, and git data for the different versionsI run git checkout release-1.0This tells my system that I want to deal with version 1.0 of the softwareI run make, which compiles the code for version 1.0This creates a library called libfoo.so.1I run make install, which installs the libraryThis copies over libfoo.so.1 into the directory /usr/local/libIt also copies over the header file foo.h into the directory /usr/local/includeThis header file is the version of foo.h that corresponds to version 1.0 of the softwareI now also want to install version 2 of the software, so I run git checkout release-2.0This tells my system that I want to deal with version 2.0 of the softwareI run make, which compiles the code for version 2.0This creates a library called libfoo.so.2I run make install, which installs the libraryThis copies over libfoo.so.2 into the directory /usr/local/libIt also copies over the header file foo.h into the directory /usr/local/includeThis header file is the version of foo.h that corresponds to version 2.0 of the softwareI now try to create a project which depends on version 2.0 of the software, and link it to libfoo.so.2 which is at /usr/local/lib, and include foo.h which is at /usr/local/includeThis project compiles and runs fineI now try to create a project which depends on version 1.0 of the software, and link it to libfoo.so.1 which is at /usr/local/lib, and include foo.h which is at /usr/local/includeThis project does not compile ok, because foo.h is the header file for version 2.0 of the software, not version 1.0.So, the thing I am puzzled about is how you can have two versions of some software installed on your machine. The actual library files libfoo.so.1 and libfoo.so.2 are both created and can be linked to by two different projects, but there is only one version of foo.h installed on the local machine. Therefore, only the version which was installed the latest will have the correct header file, because the two versions require different versions of foo.h.Please can somebody explain where I am getting confused? Thanks!
Installing multiple versions of software with git
c++;git
It's not a git problem at all. In fact, it has nothing to do with Git or even a program you're trying to install. It's just a version conflict.To solve this type of problems, there are many possible approaches:Installing each version in a separate virtual machine... in a separate Docker containersUsing smart package managers like nix which would allow you to have any number of versions of a same program installedprobably something else...In cases like this, I prefer use Docker since its' containers are lightweight (compared to virtual machines). This way, I can have any kind of environment to build and run any program. Any dependencies are installed directly in a container, so when I run my build against it, everything is already there, and my host machine is not polluted with random software.Regarding to your approach with Git. You're doing it right, but it would work anyway exactly because you can't have two versions of a same header file simultaneously. You seem to understand the problem.