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.git
- This creates a local directory
foo
, and downloads the source code and git data - This source code effectively contains all the versions of the software: source files, header file, and git data for the different versions
- I run
git checkout release-1.0
- This tells my system that I want to deal with version 1.0 of the software
- I run
make
, which compiles the code for version 1.0 - This creates a library called
libfoo.so.1
- I run
make install
, which installs the library - This copies over
libfoo.so.1
into the directory/usr/local/lib
- It also copies over the header file
foo.h
into the directory/usr/local/include
- This header file is the version of
foo.h
that corresponds to version 1.0 of the software - I now also want to install version 2 of the software, so I run
git checkout release-2.0
- This tells my system that I want to deal with version 2.0 of the software
- I run
make
, which compiles the code for version 2.0 - This creates a library called
libfoo.so.2
- I run
make install
, which installs the library - This copies over
libfoo.so.2
into the directory/usr/local/lib
- It also copies over the header file
foo.h
into the directory/usr/local/include
- This header file is the version of
foo.h
that corresponds to version 2.0 of the software - I 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 includefoo.h
which is at/usr/local/include
- This project compiles and runs fine
- I 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 includefoo.h
which is at/usr/local/include
- This 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!