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:
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.
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
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.
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?
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:
installed build deps
$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
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
build and install contrib/subtree
$ cd contrib/subtree
$ make
$ make install
$ make install-doc
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With