Can I use git without installing?

2019-02-21 09:17发布

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/

2条回答
Bombasti
2楼-- · 2019-02-21 09:39

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

查看更多
神经病院院长
3楼-- · 2019-02-21 09:55

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)

查看更多
登录 后发表回答