]> git.proxmox.com Git - libgit2.git/blob - README.md
Merge pull request #2862 from jeffhostetler/jeffhostetler/bug/branch_create_after_nam...
[libgit2.git] / README.md
1 libgit2 - the Git linkable library
2 ==================================
3
4 [![Travis Build Status](https://secure.travis-ci.org/libgit2/libgit2.svg?branch=master)](http://travis-ci.org/libgit2/libgit2)
5 [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/xvof5b4t5480a2q3/branch/master?svg=true)](https://ci.appveyor.com/project/libgit2/libgit2/branch/master)
6 [![Coverity Scan Build Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639)
7
8 `libgit2` is a portable, pure C implementation of the Git core methods
9 provided as a re-entrant linkable library with a solid API, allowing you to
10 write native speed custom Git applications in any language with bindings.
11
12 `libgit2` is licensed under a **very permissive license** (GPLv2 with a special
13 Linking Exception). This basically means that you can link it (unmodified)
14 with any kind of software without having to release its source code.
15 Additionally, the example code has been released to the public domain (see the
16 [separate license](examples/COPYING) for more information).
17
18 * Website: [libgit2.github.com](http://libgit2.github.com)
19 * StackOverflow Tag: [libgit2](http://stackoverflow.com/questions/tagged/libgit2)
20 * Issues: [GitHub Issues](https://github.com/libgit2/libgit2/issues) (Right here!)
21 * API documentation: <http://libgit2.github.com/libgit2>
22 * IRC: [#libgit2](irc://irc.freenode.net/libgit2) on irc.freenode.net.
23 * Mailing list: The libgit2 mailing list was
24 traditionally hosted in Librelist but has been deprecated. We encourage you to
25 [use StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) instead for any questions regarding
26 the library, or [open an issue](https://github.com/libgit2/libgit2/issues)
27 on GitHub for bug reports. The mailing list archives are still available at
28 <http://librelist.com/browser/libgit2/>.
29
30
31 What It Can Do
32 ==============
33
34 `libgit2` is already very usable and is being used in production for many
35 applications including the GitHub.com site, in Plastic SCM and also powering
36 Microsoft's Visual Studio tools for Git. The library provides:
37
38 * SHA conversions, formatting and shortening
39 * abstracted ODB backend system
40 * commit, tag, tree and blob parsing, editing, and write-back
41 * tree traversal
42 * revision walking
43 * index file (staging area) manipulation
44 * reference management (including packed references)
45 * config file management
46 * high level repository management
47 * thread safety and reentrancy
48 * descriptive and detailed error messages
49 * ...and more (over 175 different API calls)
50
51 Optional dependencies
52 =====================
53
54 While the library provides git functionality without the need for
55 dependencies, it can make use of a few libraries to add to it:
56
57 - pthreads (non-Windows) to enable threadsafe access as well as multi-threaded pack generation
58 - OpenSSL (non-Windows) to talk over HTTPS and provide the SHA-1 functions
59 - LibSSH2 to enable the SSH transport
60 - iconv (OSX) to handle the HFS+ path encoding peculiarities
61
62 Initialization
63 ===============
64
65 The library needs to keep track of some global state. Call
66
67 git_libgit2_init();
68
69 before calling any other libgit2 functions. You can call this function many times. A matching number of calls to
70
71 git_libgit2_shutdown();
72
73 will free the resources.
74
75 Threading
76 =========
77
78 See [THREADING](THREADING.md) for information
79
80 Building libgit2 - Using CMake
81 ==============================
82
83 `libgit2` builds cleanly on most platforms without any external dependencies.
84 Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthreads` to be available;
85 they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API
86 for threading.
87
88 The `libgit2` library is built using [CMake](<http://www.cmake.org>) (version 2.6 or newer) on all platforms.
89
90 On most systems you can build the library using the following commands
91
92 $ mkdir build && cd build
93 $ cmake ..
94 $ cmake --build .
95
96 Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace.
97
98 To install the library you can specify the install prefix by setting:
99
100 $ cmake .. -DCMAKE_INSTALL_PREFIX=/install/prefix
101 $ cmake --build . --target install
102
103 For more advanced use or questions about CMake please read <http://www.cmake.org/Wiki/CMake_FAQ>.
104
105 The following CMake variables are declared:
106
107 - `BIN_INSTALL_DIR`: Where to install binaries to.
108 - `LIB_INSTALL_DIR`: Where to install libraries to.
109 - `INCLUDE_INSTALL_DIR`: Where to install headers to.
110 - `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
111 - `BUILD_CLAR`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON)
112 - `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
113 - `STDCALL`: Build libgit2 as `stdcall`. Turn off for `cdecl` (Windows; defaults to ON)
114
115 Compiler and linker options
116 ---------------------------
117
118 CMake lets you specify a few variables to control the behavior of the
119 compiler and linker. These flags are rarely used but can be useful for
120 64-bit to 32-bit cross-compilation.
121
122 - `CMAKE_C_FLAGS`: Set your own compiler flags
123 - `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries
124 - `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`:
125 Tell CMake where to find those specific libraries
126
127 MacOS X
128 -------
129
130 If you want to build a universal binary for Mac OS X, CMake sets it
131 all up for you if you use `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"`
132 when configuring.
133
134 Windows
135 -------
136
137 You need to run the CMake commands from the Visual Studio command
138 prompt, not the regular or Windows SDK one. Select the right generator
139 for your version with the `-G "Visual Studio X" option.
140
141 See [the website](https://libgit2.github.com/docs/guides/build-and-link)
142 for more detailed instructions.
143
144 Android
145 -------
146
147 Extract toolchain from NDK using, `make-standalone-toolchain.sh` script.
148 Optionally, crosscompile and install OpenSSL inside of it. Then create CMake
149 toolchain file that configures paths to your crosscompiler (substitute `{PATH}`
150 with full path to the toolchain):
151
152 SET(CMAKE_SYSTEM_NAME Linux)
153 SET(CMAKE_SYSTEM_VERSION Android)
154
155 SET(CMAKE_C_COMPILER {PATH}/bin/arm-linux-androideabi-gcc)
156 SET(CMAKE_CXX_COMPILER {PATH}/bin/arm-linux-androideabi-g++)
157 SET(CMAKE_FIND_ROOT_PATH {PATH}/sysroot/)
158
159 SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
160 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
161 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
162
163 Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile} -DANDROID=1` to cmake command
164 when configuring.
165
166 Language Bindings
167 ==================================
168
169 Here are the bindings to libgit2 that are currently available:
170
171 * C++
172 * libqgit2, Qt bindings <https://projects.kde.org/projects/playground/libs/libqgit2/>
173 * Chicken Scheme
174 * chicken-git <https://wiki.call-cc.org/egg/git>
175 * D
176 * dlibgit <https://github.com/AndrejMitrovic/dlibgit>
177 * Delphi
178 * GitForDelphi <https://github.com/libgit2/GitForDelphi>
179 * Erlang
180 * Geef <https://github.com/carlosmn/geef>
181 * Go
182 * git2go <https://github.com/libgit2/git2go>
183 * GObject
184 * libgit2-glib <https://live.gnome.org/Libgit2-glib>
185 * Haskell
186 * hgit2 <https://github.com/fpco/gitlib>
187 * Java
188 * Jagged <https://github.com/ethomson/jagged>
189 * Julia
190 * LibGit2.jl <https://github.com/jakebolewski/LibGit2.jl>
191 * Lua
192 * luagit2 <https://github.com/libgit2/luagit2>
193 * .NET
194 * libgit2sharp <https://github.com/libgit2/libgit2sharp>
195 * Node.js
196 * node-gitteh <https://github.com/libgit2/node-gitteh>
197 * nodegit <https://github.com/tbranyen/nodegit>
198 * Objective-C
199 * objective-git <https://github.com/libgit2/objective-git>
200 * OCaml
201 * libgit2-ocaml <https://github.com/burdges/libgit2-ocaml>
202 * Parrot Virtual Machine
203 * parrot-libgit2 <https://github.com/letolabs/parrot-libgit2>
204 * Perl
205 * Git-Raw <https://github.com/jacquesg/p5-Git-Raw>
206 * PHP
207 * php-git <https://github.com/libgit2/php-git>
208 * PowerShell
209 * GitPowerShell <https://github.com/ethomson/gitpowershell>
210 * Python
211 * pygit2 <https://github.com/libgit2/pygit2>
212 * R
213 * git2r <https://github.com/ropensci/git2r>
214 * Ruby
215 * Rugged <https://github.com/libgit2/rugged>
216 * Rust
217 * git2-rs <https://github.com/alexcrichton/git2-rs>
218 * Swift
219 * Gift <https://github.com/modocache/Gift>
220 * Vala
221 * libgit2.vapi <https://github.com/apmasell/vapis/blob/master/libgit2.vapi>
222
223 If you start another language binding to libgit2, please let us know so
224 we can add it to the list.
225
226 How Can I Contribute?
227 ==================================
228
229 Check the [contribution guidelines](CONTRIBUTING.md) to understand our
230 workflow, the libgit2 [coding conventions](CONVENTIONS.md), and out list of
231 [good starting projects](PROJECTS.md).
232
233 License
234 ==================================
235
236 `libgit2` is under GPL2 **with linking exception**. This means you can link to
237 and use the library from any program, proprietary or open source; paid or
238 gratis. However, you cannot modify libgit2 and distribute it without
239 supplying the source.
240
241 See the [COPYING file](COPYING) for the full license text.