Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install subtree that ships with official Git install?

I downloaded and installed the latest Git version 1.8.4.2 from http://git-scm.com. I expected various third party Git modules such as Subtree to be available in /usr/local/git/contrib for installation. However, the contrib folder only contains a single folder (completion) inside of it and no other files or folders.

So I have two questions:

Why are modules missing from the contrib folder?

How do I install Subtree in absence of the same from the contrib folder? (I would prefer installing Subtree from official Git source rather than from https://github.com/apenwarr/git-subtree which is now an obsolete repo)

BTW, I'm running OS X Mavericks

like image 539
John Avatar asked Nov 07 '13 14:11

John


People also ask

How do I create a subtree in git?

Adding a subtreeSpecify the prefix local directory into which you want to pull the subtree. Specify the remote repository URL [of the subtree being pulled in] Specify the remote branch [of the subtree being pulled in] Specify you want to squash all the remote repository's [the subtree's] logs.

How do I install a git script?

To install Git, navigate to your command prompt shell and run the following command: sudo dnf install git-all . Once the command output has completed, you can verify the installation by typing: git version .

How does git subtree work?

git subtree allows you to nest a repository as a subdirectory inside another. It's one of the various options for managing project dependencies in Git projects. You add a subtree to an existing repository where the subtree is a reference to another repository URL and branch/tag when you wish to utilize it.


1 Answers

There are a couple ways to install git subtree on mac depending on how you installed git on your system.

With Homebrew

If you used homebrew to install git then subtree, along with the rest of the git contrib items, was already placed on your system and can be installed. To install subtree:

  1. Fire up a terminal and go to /usr/local/share/git-core/contrib/subtree.
  2. Run make which will prepare subtree.
  3. Run make prefix=/usr/local/opt/git/ install. The prefix is important because the default location the makefile knows about is not where it needs to be installed with homebrew.

Git From Installer

If you downloaded and installed git using the installer from the git website there is a different method to installing git-subtree:

  1. Since git contrib was not put on your system you'll need to checkout the git source. Don't worry about compiling or installing git. You just need access to the contrib director to install subtree (which is mostly shell scripts).
  2. In a terminal go into the git/contrib/subtree directory.
  3. Run make to prepare subtree.
  4. Run sudo make prefix=/usr install. The prefix is important for it to be installed in the right location. Note, you need to use sudo to install this because of it's location on the system.
  5. Remove the git source (unless you want to keep it around for another reason).

reference: how-to-install-git-subtree

like image 97
johnb003 Avatar answered Oct 11 '22 00:10

johnb003