How to choose install location using "apt-get install"? [duplicate]

Solution 1:

I don't know if I understood the problem correctly, so the answer goes in two directions. The first: apt-get, deb packages, and source packages. The second: Git.

The first thing to say is that apt-get install does not choose where to install a package, but the package itself specifies that information. A .deb file is just a set of compressed directories which, in fact, has the proper install targets within. So, in short, no you can't change the apt-get install destination of the packages, because it has to do with the packages, not with apt-get. Last on this, each location within a deb goes to the particular GNU/Linux directory in your system, so /usr/share/bin cannot be changed by other, the same for the "man" pages, icons, etc. Once you touch the deb, it is actually a very tricky thing to handle.

Second, of course you can work-around the paths if you know what you are doing. It is not a simple task to do for beginners or intermediate users since you need to handle the deb packaging rules to modify the deb package. To do that, just download the package without installing it with apt-get, uncompress the package and edit the deb manifest and the files/directories you may want to change. Again, this is not encouraged at all and there is no reason to do this unless you are a developer that wants to test something in particular with that package.

Third, you can always compile from the source. That will basically make a "portable" version of the software you want to install and will locate it on your home folder. Of course, it will carry a) lots of dev dependencies to build the source b) eventually solve different problems regarding the compilation. This is also not recommended for beginners, unless there is no other way to install that particular software (which clearly is not the case of Git).

But, probably you might just want to change the git location target folders? To do that you just need to configure your git account and the folders to sync. That process though has nothing to do with apt-get. Check some guides on how to do it here or here. Of course, you can always see the official page or the man page of git (man git in a shell).