Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I correctly install the tools in git's contrib directory?

Tags:

Git includes a set of tools contributed by third parties. I'm not sure how I'm supposed to use these tools correctly.

For example, I'd like to use git-subtree. There seem to be a number of ways I could use this:

  1. Copy to my path

     cp /path/to/git-subtree.sh /usr/local/bin/git-subtree
     chmod +x /usr/local/bin/git-subtree
    

    Works fine, feels a bit hacky.

  2. Symlink to my path

     chmod +x /path/to/git-subtree.sh
     ln -s /path/to/git-subtree.sh /usr/local/bin/git-subtree
    

    Also works, feels marginally less hacky

  3. Use a git alias

    Add the following to my global .gitconfig file:

     [alias]
         subtree = !/path/to/git-subtree.sh
    

    Then good old chmod again:

     chmod +x /path/to/git-subtree.sh
    

    Works, feels all nice and git-ish.

  4. Use the Makefile

    Per the INSTALL file.

     cd /path/to/git-subtree.sh
     make
     make install
     make install-doc
    

    Doesn't work for me, it tries to install to a non-existent path. Perhaps this is because I installed git using homebrew rather than installing from source? I'm too lazy to investigate; I already have three working alternatives. :)

So my question is, which of these is the preferred way of installing git-contrib add-ons? Is there even a preferred way? Is there another option I haven't suggested that's better than the ones listed above?

like image 616
Simon Whitaker Avatar asked Jul 22 '12 19:07

Simon Whitaker


3 Answers

from git/contrib/git-subtree:

HOW TO INSTALL git-subtree
==========================

First, build from the top source directory.

Then, in contrib/subtree, run:

 make
 make install
 make install-doc

If you used configure to do the main build the git-subtree build will pick up those settings. If not, you will likely have to provide a value for prefix:

 make prefix=<some dir>
 make prefix=<some dir> install
 make prefix=<some dir> install-doc

To run tests first copy git-subtree to the main build area so the newly-built git can find it:

 cp git-subtree ../..

Then:

 make test

I just verified that this works:

  1. downloaded source via existing git
  2. installed build deps

    $ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
    
  3. check out the latest release branch and build

    $ git co v1.7.11.3  
    $ make prefix=/usr/local all  
    $ sudo make prefix=/usr/local install  
    
  4. build and install contrib/subtree

    $ cd contrib/subtree  
    $ make  
    $ make install  
    $ make install-doc   
    
  5. verify it all works

    /usr/local/bin/git  
    [todd@montreal-01 subtree ((v1.7.11.3))]$ git --version  
    git version 1.7.11.3  
    

Check, we have the latest git.

[todd@montreal-01 subtree ((v1.7.11.3))]$ git subtree  
usage: git subtree add   --prefix=<prefix> <commit>  
    or: git subtree merge --prefix=<prefix> <commit>  
    or: git subtree pull  --prefix=<prefix> <repository> <refspec...>  
    or: git subtree push  --prefix=<prefix> <repository> <refspec...>  
    or: git subtree split --prefix=<prefix> <commit...>

    -h, --help            show the help  
    -q                    quiet  
    -d                    show debug messages  
    -P, --prefix ...      the name of the subdir to split out  
    -m, --message ...     use the given message as the commit message for the merge commit  

options for 'split'  
    --annotate ...        add a prefix to commit message of new commits  
    -b, --branch ...      create a new branch from the split subtree  
    --ignore-joins        ignore prior --rejoin commits  
    --onto ...            try connecting new tree to an existing one  
    --rejoin              merge the new branch back into HEAD  

options for 'add', 'merge', 'pull' and 'push'  
    --squash              merge subtree changes as a single commit  

Check, we have subtree working.

like image 197
toddg Avatar answered Sep 24 '22 09:09

toddg


Here's the simplest thing that worked for me, installing git-subtree on Ubuntu 12.10:

Get the code

git clone https://github.com/git/git.git --depth=1
cd git/contrib/subtree
make

"Install" it into the git tools directory

sudo cp git-subtree /usr/lib/git-core/

For the man page, you need asciidoc which is not a small installation, but if you have it:

make doc
gzip git-subtree.1
sudo cp git-subtree.1.gz /usr/share/man/man1

And that's it.

like image 27
itsadok Avatar answered Sep 23 '22 09:09

itsadok


Contribs is a collection of helpful things. You don't install them as a package. For example, to install the tab completion, you simply source that script from your .bash_profile script. Each contrib in that folder has it's own way of using it.

as for compiling git from source

make
sudo make install

after you install all the prerequisites.

like image 41
Adam Dymitruk Avatar answered Sep 20 '22 09:09

Adam Dymitruk