15

I have heard good things about git and I would like to try it out before installing it. This would also be great to put it on a flash drive if I wanted to use git at school. Is it possible to use the full path like /path/to/git init?

I primarily use Mac OS X so the question is mostly directed for Mac, but I would also like to know if it is possible on other OS's as well.

EDIT:

Compiling from source works. I used the following commands:

cd git-1.7.5.1 #this is the decompressed dir containing src
make configure
./configure --prefix=/path/to/install/git
make all
sudo make install

The downside to this method is that once compiled, the directory is a hefty 200MB. That is why I chose jgit as the answer. jgit.sh is less than 2MB and supports the following commands:

add       Add file contents to the index
branch    List, create, or delete branches
checkout  Checkout a branch to the working tree
clone     Clone a repository into a new directory
commit    Record changes to the repository
daemon    Export repositories over git://
diff      Show diffs
fetch     Update remote refs from another repository
init      Create an empty git repository
log       View commit history
merge     Merges two development histories
push      Update remote repository from local refs
rm        Stop tracking a file
tag       Create a tag
version   Display the version of jgit

You can download jgit.sh here http://www.eclipse.org/jgit/download/

styfle
  • 22,361
  • 27
  • 86
  • 128
  • installing git isnt THAT much of a commitment. even if you dont uninstall it, im sure you wont notice the few megs it takes up. – Matt Briggs May 05 '11 at 04:39
  • 2
    @Matt I wasn't even sure if you could completely uninstall it. Hopefully the uninstall would change the path back to how it was before. I don't like installing only to uninstall the same day. There's always something that gets left behind :/ – styfle May 05 '11 at 04:47
  • Can you give an example of a file which is left after an uninstall? – Blender May 05 '11 at 04:48
  • @Blender After a git uninstall? I was talking about in general. Usually files are left behind such as profile settings. And like I said, I don't know if the path would change. In fact, I don't know what installers are installing so how would I know if it completely uninstalled? – styfle May 05 '11 at 04:59
  • 1
    You don't have to install `git` with an installer. You just download the source tarball, extract it, `cd` into the directory, and run `./configure --prefix=/path/to/install/folder/`, `make`, and `make install`. From there, `cd` into the `bin` folder and run it. – Blender May 05 '11 at 05:18
  • When you're all done, just delete that folder. Nothing was installed elsewhere. – Blender May 05 '11 at 05:19
  • @Blender After compiling, the directory I compiled to is 200MB. Is that about the amount of space git uses after a normal install? – styfle May 06 '11 at 22:52
  • After compiling the source, you can also run without installing by calling bin-wrappers/git as described in [INSTALL](https://github.com/git/git/blob/v1.7.1/INSTALL#L41-L45). – Glen K Jun 28 '18 at 21:59
  • @MattBriggs, you'll be surprised about your privilege. – Pacerier Jul 20 '19 at 08:26

2 Answers2

10

Or you can try out JGit, it is a single bash file that you can run basic Git commands. Git is self contained in that bash script.

To download JGit, choose the second link (Self contained command line executable) located here http://www.eclipse.org/jgit/download/ once downloaded, rename it to jgit.sh and just run it: jgit.sh (remember to chmod +x jgit.sh)

Mohamed Mansour
  • 39,445
  • 10
  • 116
  • 90
  • Interesting. Is this just a Java implementation of git? It seems a bit slow but it's very small (less than 2MB). How can I find out what commands are supported? – styfle May 05 '11 at 05:43
  • @Blender I'm slow. The commands are listed when you run the script. – styfle May 05 '11 at 06:12
  • Yea, JGit is a pure Java implementation of Git. It is slower in some commands but it is being used in large production environments such as Android/Eclipse etc. It is light weight and pretty cool to have it in a single file, cross platform! – Mohamed Mansour May 05 '11 at 23:16
  • 1
    When you say "just run it", how exactly do you do that? – CodyBugstein Oct 02 '15 at 18:51
  • @MohamedMansour, https://www.quora.com/unanswered/Does-eclipse-Android-really-use-jgit-instead-of-git – Pacerier Jul 13 '19 at 00:13
3

Can't you just compile it from source, using --prefix=/path/to/install/folder/ and just make install it to that folder?

Blender
  • 289,723
  • 53
  • 439
  • 496
  • I successfully built the code using the following commands: `cd git-1.5.2.4` `make configure` `./configure --prefix=/path/to/git` `make all` `sudo make install` – styfle May 05 '11 at 05:49