• This repository has been archived on 11/Sep/2020
  • Stars
    star
    4,913
  • Rank 8,120 (Top 0.2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Project has been moved to: https://github.com/go-git/go-git

WE CONTINUE THE DEVELOPMENT AT go-git/go-git. This repository is abandoned, and no further updates will be done on the code base, nor issue/prs will be answered or attended.

go-git logo GoDoc Build Status Build status codecov.io Go Report Card

go-git is a highly extensible git implementation library written in pure Go.

It can be used to manipulate git repositories at low level (plumbing) or high level (porcelain), through an idiomatic Go API. It also supports several types of storage, such as in-memory filesystems, or custom implementations thanks to the Storer interface.

It's being actively developed since 2015 and is being used extensively by source{d} and Keybase, and by many other libraries and tools.

Comparison with git

go-git aims to be fully compatible with git, all the porcelain operations are implemented to work exactly as git does.

git is a humongous project with years of development by thousands of contributors, making it challenging for go-git to implement all the features. You can find a comparison of go-git vs git in the compatibility documentation.

Installation

The recommended way to install go-git is:

go get -u gopkg.in/src-d/go-git.v4/...

We use gopkg.in to version the API, this means that when go get clones the package, it's the latest tag matching v4.* that is cloned and not the master branch.

Examples

Please note that the CheckIfError and Info functions used in the examples are from the examples package just to be used in the examples.

Basic example

A basic example that mimics the standard git clone command

// Clone the given repository to the given directory
Info("git clone https://github.com/src-d/go-git")

_, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
    URL:      "https://github.com/src-d/go-git",
    Progress: os.Stdout,
})

CheckIfError(err)

Outputs:

Counting objects: 4924, done.
Compressing objects: 100% (1333/1333), done.
Total 4924 (delta 530), reused 6 (delta 6), pack-reused 3533

In-memory example

Cloning a repository into memory and printing the history of HEAD, just like git log does

// Clones the given repository in memory, creating the remote, the local
// branches and fetching the objects, exactly as:
Info("git clone https://github.com/src-d/go-siva")

r, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
    URL: "https://github.com/src-d/go-siva",
})

CheckIfError(err)

// Gets the HEAD history from HEAD, just like this command:
Info("git log")

// ... retrieves the branch pointed by HEAD
ref, err := r.Head()
CheckIfError(err)


// ... retrieves the commit history
cIter, err := r.Log(&git.LogOptions{From: ref.Hash()})
CheckIfError(err)

// ... just iterates over the commits, printing it
err = cIter.ForEach(func(c *object.Commit) error {
	fmt.Println(c)
	return nil
})
CheckIfError(err)

Outputs:

commit ded8054fd0c3994453e9c8aacaf48d118d42991e
Author: Santiago M. Mola <[email protected]>
Date:   Sat Nov 12 21:18:41 2016 +0100

    index: ReadFrom/WriteTo returns IndexReadError/IndexWriteError. (#9)

commit df707095626f384ce2dc1a83b30f9a21d69b9dfc
Author: Santiago M. Mola <[email protected]>
Date:   Fri Nov 11 13:23:22 2016 +0100

    readwriter: fix bug when writing index. (#10)

    When using ReadWriter on an existing siva file, absolute offset for
    index entries was not being calculated correctly.
...

You can find this example and many others in the examples folder.

Contribute

Contributions are more than welcome, if you are interested please take a look to our Contributing Guidelines.

License

Apache License Version 2.0, see LICENSE

More Repositories

1

awesome-machine-learning-on-source-code

Cool links & research papers related to Machine Learning applied to source code (MLonCode)
6,126
star
2

gitbase

SQL interface to git repositories, written in Go. https://docs.sourced.tech/gitbase
Go
2,050
star
3

hercules

Gaining advanced insights from Git repository history.
Go
2,009
star
4

go-mysql-server

An extensible MySQL server implementation in Go.
Go
1,038
star
5

go-kallax

Kallax is a PostgreSQL typesafe ORM for the Go language.
Go
859
star
6

kmcuda

Large scale K-means and K-nn implementation on NVIDIA GPU / CUDA
Jupyter Notebook
772
star
7

proteus

Generate .proto files from Go source code.
Go
733
star
8

wmd-relax

Calculates Word Mover's Distance Insanely Fast
Python
457
star
9

enry

A faster file programming language detector
Go
454
star
10

datasets

source{d} datasets ("big code") for source code analysis and machine learning on source code
Jupyter Notebook
317
star
11

guide

Aiming to be a fully transparent company. All information about source{d} and what it's like to work here.
JavaScript
292
star
12

lapjv

Linear Assignmment Problem solver using Jonker-Volgenant algorithm - Python 3 native module.
C++
238
star
13

go-license-detector

Reliable project licenses detector.
Go
234
star
14

engine-deprecated

[DISCONTINUED] Go to https://github.com/src-d/sourced-ce/
Go
217
star
15

go-billy

The missing interface filesystem abstraction for Go
Go
197
star
16

sourced-ce

source{d} Community Edition (CE)
Go
184
star
17

beanstool

Dependency free beanstalkd admin tool
Go
151
star
18

lookout

Assisted code review, running custom code analyzers on pull requests
Go
149
star
19

ml

sourced.ml is a library and command line tools to build and apply machine learning models on top of Universal Abstract Syntax Trees
Python
141
star
20

reading-club

Paper reading club at source{d}
115
star
21

minhashcuda

Weighted MinHash implementation on CUDA (multi-gpu).
C++
110
star
22

go-siva

siva - seekable indexed verifiable archiver
Go
97
star
23

jgit-spark-connector

jgit-spark-connector is a library for running scalable data retrieval pipelines that process any number of Git repositories for source code analysis.
Scala
71
star
24

gitbase-web

gitbase web client; source{d} CE comes with a new UI, check it at https://docs.sourced.tech/community-edition/
Go
57
star
25

gemini

Advanced similarity and duplicate source code at scale.
Scala
54
star
26

apollo

Advanced similarity and duplicate source code proof of concept for our research efforts.
Python
52
star
27

borges

borges collects and stores Git repositories.
Go
52
star
28

go-queue

Queue is a generic interface to abstract the details of implementation of queue systems.
Go
46
star
29

vecino

Vecino is a command line application to discover Git repositories which are similar to the one that the user provides.
Python
46
star
30

okrs

Objectives & Key Results repository for the source{d} team
46
star
31

jgscm

Jupyter support for Google Cloud Storage
Python
45
star
32

code2vec

MLonCode community effort to implement Learning Distributed Representations of Code (https://arxiv.org/pdf/1803.09473.pdf)
Python
40
star
33

coreos-nvidia

Yet another NVIDIA driver container for Container Linux (aka CoreOS)
Makefile
37
star
34

style-analyzer

Lookout Style Analyzer: fixing code formatting and typos during code reviews
Jupyter Notebook
32
star
35

code-annotation

🐈 Code Annotation Tool
JavaScript
28
star
36

flamingo

Flamingo is a very thin and simple platform-agnostic chat bot framework
Go
27
star
37

blog

source{d} blog
HTML
27
star
38

sparkpickle

Pure Python implementation of reading SequenceFile-s with pickles written by Spark's saveAsPickleFile()
Python
24
star
39

go-errors

Yet another errors package, implementing error handling primitives.
Go
22
star
40

infrastructure-dockerfiles

Dockerfile-s to build the images which power source{d}'s computing infrastructure.
Dockerfile
22
star
41

conferences

Tracking events, CfPs, abstracts, slides, and all other even related things
22
star
42

tmsc

Python
21
star
43

homebrew

Real homebrew!
21
star
44

models

Machine learning models for MLonCode trained using the source{d} stack
19
star
45

terraform-provider-online

Terraform provider for Online.net
Go
19
star
46

modelforge

Python library to share machine learning models easily and reliably.
Python
18
star
47

identity-matching

source{d} extension to match Git signatures to real people.
Go
17
star
48

tensorflow-swivel

C++
16
star
49

seriate

Optimal ordering of elements in a set given their distance matrix.
Python
16
star
50

go-vitess

An automatic filter-branch of Go libraries from the great Vitess project.
Go
15
star
51

gitcollector

Go
14
star
52

rovers

Rovers is a service to retrieve repository URLs from multiple repository hosting providers.
HTML
14
star
53

ml-core

source{d} MLonCode foundation - core algorithms and models.
Python
14
star
54

go-parse-utils

Go
14
star
55

charts

Applications for Kubernetes
Smarty
12
star
56

role2vec

TeX
12
star
57

snippet-ranger

Jupyter Notebook
12
star
58

fsbench

a small tool for benchmarking filesystems
Go
11
star
59

dev-similarity

Jupyter Notebook
11
star
60

go-log

Log is a generic logging library based on logrus
Go
11
star
61

tab-vs-spaces

Jupyter Notebook
10
star
62

ghsync

GitHub API v3 > PostgreSQL
Go
9
star
63

diffcuda

Accelerated bulk diff on GPU
C
9
star
64

ml-mining

Python
8
star
65

go-billy-siva

A limited go-billy filesystem implementation based on siva.
Go
8
star
66

go-compose-installer

A toolkit to create installers based on docker compose.
Go
8
star
67

github-reminder

A GitHub application to handle deadline reminders in a GitHub idiomatic way.
Go
8
star
68

go-git-fixtures

several git fixtures to run go-git tests
Go
8
star
69

docsrv

docsrv is an app to serve versioned documentation for GitHub projects on demand
Go
7
star
70

go-cli

CLI scaffolding for Go
Go
7
star
71

shell-complete

Python
7
star
72

engine-analyses

Analyses of open source projects with source{d} Engine
Jupyter Notebook
7
star
73

kubernetes-local-pv-provisioner

Helping you setting up local persistent volumes
Go
7
star
74

gypogit

[UNMAINTAINED] go-git wrapper for Python
Python
6
star
75

go-borges

Go
6
star
76

treediff

Python
6
star
77

engine-tour

Temporary storage for useful guides for the source{d} engine
Jupyter Notebook
6
star
78

jupyter-spark-docker

Dockerfile with jupyter and scala installed
Dockerfile
6
star
79

imports

Go
6
star
80

git-validate

Go
6
star
81

k8s-pod-headless-service-operator

Go
6
star
82

sourced-ui

source{d} UI
JavaScript
6
star
83

ci

Make-based build system for Go projects at source{d}
Shell
5
star
84

landing

landing for source{d}
HTML
5
star
85

lookout-terraform-analyzer

This is a lookout analyzer that checks if your PR has been Terraform fmt'ed when submitting it.
Go
5
star
86

swivel-spark-prep

Distributed equivalent of prep.py and fastprep from Swivel using Apache Spark.
Scala
5
star
87

platform-starter

Starter and basic configuration for platform frontend projects.
Go
4
star
88

metadata-retrieval

Go
4
star
89

lookout-sdk

SDK for lookout analyzers
Python
4
star
90

code-completion

autocompletion prototype
Python
4
star
91

siva-java

siva format implemented in Java
Java
4
star
92

design

All things design at source{d}: branding, guidelines, UI assets, media & co.
4
star
93

berserker

Large scale UAST extractor [DEPRECATED]
Shell
4
star
94

framework

[DEPRECATED]
Go
4
star
95

combustion

Go
3
star
96

tm-experiments

Topic Modeling Experiments on Source Code
Python
3
star
97

go-YouTokenToMe

Go
3
star
98

lookout-sdk-ml

SDK for ML based Lookout analyzers
Python
3
star
99

go-asdf

Advanced Scientific Data Format reader library in pure Go.
Go
3
star
100

google-cloud-dns-healthcheck

Go
3
star