A highly extensible Git implementation in pure Go.

Overview

go-git logo GoDoc Build Status 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 Keybase, Gitea or Pulumi, and by many other libraries and tools.

Project Status

After the legal issues with the src-d organization, the lack of update for four months and the requirement to make a hard fork, the project is now back to normality.

The project is currently actively maintained by individual contributors, including several of the original authors, but also backed by a new company, gitsight, where go-git is a critical component used at scale.

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:

import "github.com/go-git/go-git/v5" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/go-git/go-git" // with go modules disabled

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/go-git/go-git")

_, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
    URL:      "https://github.com/go-git/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/go-git/go-billy")

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

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

Comments
  • plumbing: format/packfile, prevent large objects from being read into memory completely

    plumbing: format/packfile, prevent large objects from being read into memory completely

    This PR adds code to prevent large objects from being read into memory from packfiles or the filesystem through the use of a new Option, the LargeObjectThreshold.

    Objects greater than the provided (optional) LargeObjectThreshold are now no longer directly stored in the cache or read completely into memory.

    This PR differs and improves the previous broken #303 by fixing several bugs in the reader and transparently wrapping ReaderAt as a Reader.

    Signed-off-by: Andrew Thornton [email protected]


    (UPDATED: Make LOT an Option on the ObjectStorage - defaulted to off.)

    opened by zeripath 20
  • pumbling: packfile, resolve external reference delta

    pumbling: packfile, resolve external reference delta

    I don't really want to take any credit for this work. This solution is a carbon copy of what was proposed in https://github.com/go-git/go-git/pull/111

    Would really appreciate some feedback

    opened by ga-paul-t 19
  • Support build under wasm and/or js

    Support build under wasm and/or js

    Fixes the following build error under GOOS=js GOARCH=wasm go build -v:

    package github.com/go-git/go-git/v5        
            imports github.com/go-git/go-billy/v5/osfs
            imports golang.org/x/sys/unix: build constraints exclude all Go files in /home/paralin/go/pkg/mod/golang.org/x/[email protected]/unix
    
    opened by paralin 15
  • config: support insteadOf for remotes' URLs

    config: support insteadOf for remotes' URLs

    Added support for insteadOf configuration for remote's urls. Can also be applied to submodules, but I didn't implement that.

    This fixes: https://github.com/go-git/go-git/issues/76

    opened by kostyay 11
  • git-ssh: try multiple algorithms for known_hosts

    git-ssh: try multiple algorithms for known_hosts

    Hi,

    When using git over ssh, it seems that if a host (eg: GitHub.com) has multiple keys (eg: an rsa and an ed25519 ones), but only one of those keys is listed in the $HOME/.ssh/known_hosts, and the one that's not listed has a higher preference (e.g. ed25519 over rsa), then the git clone operation will fail.

    I feel it should try to be more intelligent and try to use the rsa one.

    opened by franklouwers 8
  • Fix object not found error in OFS deltas

    Fix object not found error in OFS deltas

    Unfortunately the code in #303 was incorrect for large objects in OFS deltas.

    The underlying fault is that the seeker in the packfile was seeking away whilst the delta was being read.

    This PR simply reads the delta into a buffer.

    Fix #323

    Signed-off-by: Andrew Thornton [email protected]

    opened by zeripath 7
  • plumbing: wire up contexts for Transport.AdvertisedReferences

    plumbing: wire up contexts for Transport.AdvertisedReferences

    This is primarily for the sake of the http transport, which otherwise makes its first call without a context, causing context timeouts to not work if the remote is unresponsive.

    Fixed up several tests which were getting this wrong. I am particularly fond of the ones which canceled the context and then proceeded to test that the function worked after being canceled.

    The AdvertisedReferences function can be removed after this change, but this is technically breaking the API, since library users could call it, so it should really be deferred to v6.

    opened by asuffield 7
  •  authentication required

    authentication required

    I am cloning a private library

    And comes with a username and password

    But this doesn't seem to work and got authentication required error

    	options := git.CloneOptions{
    		URL:               getGitURL(r.repo, username, password), // https://username:[email protected]/owner/repo.git
    		Progress:          os.Stdout,
    		SingleBranch:      true,
    		Depth:             1,
    		RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
    	}
    
    	_, err := git.CloneContext(ctx, memory.NewStorage(), fs, &options)
    
    opened by axetroy 7
  • config: add missing functions for completeness

    config: add missing functions for completeness

    This PR complete the Config functions.

    Add Options.Has to check if an Option exist.

    Wherever a collection of Option exist, make sure that the following functions exists as well:

    • Option
    • OptionAll (new, return all values)
    • HasOption (new)
    • AddOption
    • SetOption
    • RemoveOption

    For Config and Section, make sure that the following exist to access the sublevel:

    • X
    • HasX (HasSection was missing)
    • RemoveX (RemoveSubsection was missing)

    This PR also does some shuffling to have a consistent ordering of functions.

    opened by MichaelMure 7
  • plumbing: diff, add colored output support

    plumbing: diff, add colored output support

    Fixes #33.

    This is a draft PR. Please tell me if it more-or-less follows the project's coding style and what changes are likely to be needed to make it more acceptable.

    At the moment, it only supports the default git diff colors as defined by git 2.26.2. It should be extensible to reading custom colors from a git config file, if needed.

    Before merging, this needs a few tweaks to ensure the output matches git's as far as reasonably possible.

    opened by twpayne 7
  • plumbing: format, config.Merged to allow access to local and global config

    plumbing: format, config.Merged to allow access to local and global config

    ...for reading and writing global (~/.gitconfig) and reading system (/etc/gitconfig) configs in addition to local repo config.

    This is heavily based on / inspired by @djgilcrease's PR on the original src-d repo: https://github.com/src-d/go-git/pull/1243. However, I ran into an issue using that code where if you ran SetConfig it would write out the merged system, global, and local config params all to your local ./.git/config file, which was hard to fix under that architecture.

    So, I tried to take a simpler starting approach with this PR but still allow it to accomplish my 2 goals:

    1. Show a merged view of system (/etc/gitconfig), global (~/.gitconfig), and local (./.git/config) configs with the same precedence ordering that git itself uses (local overrides global overrides system).
    2. Allow setting / changing options in any of these files (with the exception of setting system options b/c we typically won't have permission to write to that file).

    The way I did this was basically to leave the higher-level config stuff (e.g. .Remotes, .Core.IsBare) alone and add a new .Merged param that works similarly to .Raw but brings in these other configs. So now you can see the merged view with things like .Merged.Section("foo").Option("bar") (which is all read-only) or set options with things like .Merged.GlobalConfig().AddOption(...). .Raw now delegates to .Merged.LocalConfig().

    I added a config example to demonstrate some of the usage and a couple of tests of marshalling and unmarshalling the different configs.

    opened by cap10morgan 7
  • feat(repo): Add ability to get latest tag from commit

    feat(repo): Add ability to get latest tag from commit

    This adds a new function LatestTag to Repository that allows getting the latest tag in the commit history from a given commit. It allows achieving something that git describe --tag does.

    Fixes #451

    opened by MisterMX 0
  • got

    got "unknown error: remote:" error from handleAdvRefDecodeError method

    Hi folks!

    I came here from https://github.com/argoproj/argo-cd/issues/4441

    ArgoProj / ArgoCD calls AdvertisedReferences to find sha commit from HEAD / branch / tag

    When ssh key provided to access gitlab repository does not have rights to read from it we got this output from ssh

    git clone  [email protected]:m.nacharov/argocd-issue-4441.git
    Cloning into 'argocd-issue-4441'...
    remote: 
    remote: ========================================================================
    remote: 
    remote: ERROR: The project you were looking for could not be found or you don't have permission to view it.
    
    remote: 
    remote: ========================================================================
    remote: 
    fatal: Could not read from remote repository.
    

    but only first line passes to the error message (in checkNotFoundError method)

    Proposal

    May be we could add some logic for those "remote:" lines to have an error with a meaningful message? Or just read the hole stderr?

    I would actually prefer to have a message like this

    remote: ERROR: The project you were looking for could not be found or you don't have permission to view it.
    fatal: Could not read from remote repository.
    
    opened by mnacharov 0
  • Checkout doesn't function like `git checkout <branch-name>` when switching to a remote branch

    Checkout doesn't function like `git checkout ` when switching to a remote branch

    When you clone a repository with say master branch - git clone <https://some-repo-url> and then you try to checkout to a different branch that exists on remote - git checkout <remote-branch>, this switches to a new branch and the effect is like in the following example message Branch 'remote-branch' set up to track remote branch 'remote-branch' from 'origin'. Switched to a new branch 'remote-branch'

    I tried this:

    repo.Checkout(repoWorktree, &git.CheckoutOptions{
    	Branch: some-branch-name,
    	Keep:  true,
    })
    

    and

    1. It moves folders from one branch to the other, howbeit empty. This is not exactly the same effect as git checkout <branch-name> which just switches to a branch and sets it to track from origin (no extra folders).
    2. Setting keep: true on checkout shows un-committed changes (i.e., on checkout to another branch, it shows the files from the other branch as deleted when you do a git status). This is also not the same effect as traditional git checkout Is there a way to keep ONLY changes made on local files?

    I also tried this approach https://github.com/go-git/go-git/issues/241, where I created a symbolic reference between local and remote branch to no avail

    newReference := plumbing.NewSymbolicReference(localRefName, remoteRefName)
    err = repo.Storer.SetReference(newReference)
    
    opened by Ileriayo 0
  • relative path is not expanded for an ssh remote like with git (and ssh itself)

    relative path is not expanded for an ssh remote like with git (and ssh itself)

    Normally if a user has a repository bar in folder foo in their home on the server, one can add this as a ssh remote to git with only the relative path and things work like expected:

    $ git remote -v
    origin	server:foo/bar (fetch)
    origin	server:foo/bar (push)
    

    However, with go-git fetching or pulling from this remote results in the error "repository not found". If the remote is added with the full path it works without a problem:

    $ git remote -v
    origin	server:/home/user/foo/bar (fetch)
    origin	server:/home/user/foo/bar (push)
    
    opened by ewintr 0
  • Support `~` and `~user` in readIgnoreFile

    Support `~` and `~user` in readIgnoreFile

    See also https://github.com/apache/skywalking-eyes/pull/133#pullrequestreview-1095785619.

    And git supports this feature by:

    /*
     * Return a string with ~ and ~user expanded via getpw*. Returns NULL on getpw
     * failure or if path is NULL.
     *
     * If real_home is true, strbuf_realpath($HOME) is used in the `~/` expansion.
     *
     * If the path starts with `%(prefix)/`, the remainder is interpreted as
     * relative to where Git is installed, and expanded to the absolute path.
     */
    char *interpolate_path(const char *path, int real_home)
    {
    	struct strbuf user_path = STRBUF_INIT;
    	const char *to_copy = path;
    
    	if (!path)
    		goto return_null;
    
    	if (skip_prefix(path, "%(prefix)/", &path))
    		return system_path(path);
    
    	if (path[0] == '~') {
    		const char *first_slash = strchrnul(path, '/');
    		const char *username = path + 1;
    		size_t username_len = first_slash - username;
    		if (username_len == 0) {
    			const char *home = getenv("HOME");
    			if (!home)
    				goto return_null;
    			if (real_home)
    				strbuf_add_real_path(&user_path, home);
    			else
    				strbuf_addstr(&user_path, home);
    #ifdef GIT_WINDOWS_NATIVE
    			convert_slashes(user_path.buf);
    #endif
    		} else {
    			struct passwd *pw = getpw_str(username, username_len);
    			if (!pw)
    				goto return_null;
    			strbuf_addstr(&user_path, pw->pw_dir);
    		}
    		to_copy = first_slash;
    	}
    	strbuf_addstr(&user_path, to_copy);
    	return strbuf_detach(&user_path, NULL);
    return_null:
    	strbuf_release(&user_path);
    	return NULL;
    }
    
    opened by tisonkun 0
Releases(v5.4.2)
  • v5.4.2(Jun 2, 2021)

  • v5.4.1(May 24, 2021)

  • v5.4.0(May 22, 2021)

    Change Log

    • Repository: test, use raw string to avoid double-escape #288 (jeffwidman)
    • Remote: new ListContext function #278 (xiujuan95)
    • Remote: add support for deepening shallow clones #311 (marwatk)
    • Submodele, fetch submodules pointing to orphaned but still reachable commits #284 (edigaryev)
    • plumbing: object/patch, printStat strings.Repeat cause panic #310 (cookeem)
    • plumbing: format/packfile, prevent large objects from being read into memory completely #303 (zeripath)
    • plumbing: transport/ssh, support more formats in NewPublicKeys SSH helper #298 (hiddeco)
    • *: replace golang.org/x/crypto/openpgp by github.com/ProtonMail/go-crypto/openpgp #283 (johanfleury)
    • *: typo fixes #291 (jeffwidman)
    • *: minor doc fixes #287 (jeffwidman)
    • *: remove unused unexported const #286 (jeffwidman)
    Source code(tar.gz)
    Source code(zip)
  • v5.3.0(Mar 29, 2021)

    Change Log

    • transport: ssh, fix cloning large repositories #272 (dcu)
    • diff: Allow srcPrefix and dstPrefix to be configured #265 (yabberyabber)
    • Remote: add RequireRemoteRefs to PushOptions #258 (asuffield)
    • plumbing: gitignore, Fix gitconfig path in LoadSystemPatterns doc #256 (andrewarchi)
    • plumbing: wire up contexts for Transport.AdvertisedReferences #246 (asuffield)
    • worktree: Don't remove root directory when cleaning #230 (hansmi)
    • *: add insecureSkipTLS and cabundle #228 (StrongMonkey)
    • git: worktree_commit, just store objects not already stored #224 (jsteuer)
    • plumbing: packp: adding "object-format" and "filter" capabilities #222 (rofc)
    • Submodule: fix relative submodule resolution #195 (adracus)
    • git: worktree, Support relative submodule URL. #184 (mikyk10)
    • config: add init.defaultBranch to the config #178 (tomlazar)
    • config: support insteadOf for remotes' URLs #79 (kostyay)
    Source code(tar.gz)
    Source code(zip)
  • v5.2.0(Oct 9, 2020)

    Change Log

    Source code(tar.gz)
    Source code(zip)
  • v5.1.0(May 24, 2020)

    This version includes three main relevant features, the long-awaited support for renames on diff by hash and similar content (#38, #42), color diff support (#40), and support for work with git config from different scopes and Worktree.Commit with an empty CommitOptions (#75)

    Change Log

    • Repository.ConfigScoped and Worktree.Commit with empty CommitOptions (#75)
    • Remote.Push: support force option (#71)
    • Remote.Fetch: support exact SHA1 refspecs (#58)
    • plumbing: diff, reset color at end of line (#66)
    • plumbing: object, Commit.Patch support to as nil (#62)
    • plumbing: object, Fixed the ambiguous implicit conversions causing errors while building . (#57)
    • plumbing: object, make renames diff default (#42)
    • plumbing: exact renames detection could leave gaps in the changes (#54)
    • plumbing: diff, add colored output support. (#40)
    • plumbing: detect renames by hash and similar content in diff tree (#38)
    • plumbing: transport, fix handling of empty adv-refs on upload-pack (#22)
    • plumbing: transport server check for nil Packfile, fixes ref deletes (#11)
    • plumbing/storage: close Reader & Writer of EncodedObject after use (#73)
    • storage/filesystem: dotgit, sanity check provided reference path (#39)
    Source code(tar.gz)
    Source code(zip)
  • v5.0.0(Mar 15, 2020)

    This new v5.0.0 it's based on v4.13.1containaing exactly the same API. The new version and all the future versions in v5 branch can be used as a drop-in replacement for v4. This big change is required due to the new project home at go-git org and the full adoption of go modules.

    As described in the README.md, after four months of inactivity the go-git project is back to life. Sorry for any inconvenience caused.

    Change Log

    • *: package name renamed to github.com/go-git/go-git/v5 (https://github.com/go-git/go-git/commit/2bdfd91f04068220a72feeade31defc09f2a601e)
    • *: ci based on github actions (https://github.com/go-git/go-git/commit/9d0f15c4fa712cdacfa3887e9baac918f093fbf6)
    • *: add Plan 9 support (https://github.com/go-git/go-git/pull/1)
    • git.LogOptions: add PathFilter func(string) bool (https://github.com/go-git/go-git/pull/3)
    • plumbing: object, fix date reading (https://github.com/go-git/go-git/pull/2)
    • storage/filesystem: dotgit, unable to work with .git folder with temporal packfiles (https://github.com/go-git/go-git/pull/6)
    • plumbing/object: avoid O(N^2) string building when decoding commit message (https://github.com/go-git/go-git/pull/7)
    Source code(tar.gz)
    Source code(zip)
  • v4.13.1(Mar 9, 2020)

    Fix build in linux/386

    Change Log

    • worktree: force convert to int64 to support 32bit os. Fix #1202 (https://github.com/src-d/go-git/pull/1203)
    Source code(tar.gz)
    Source code(zip)
  • v4.13.0(Mar 9, 2020)

    Not very fancy release, with some code improvements and cleans and the update of all the dependencies. The most relevant change is the #1197, making public http.AuthMethod.SetAuth method.

    Change Log

    Source code(tar.gz)
    Source code(zip)
  • v4.12.0(Mar 9, 2020)

    This new release comes with two relevant contributions, the first one is the experimental support of commit-graph support by (filipnavara) nd the second one is merge-base feature contributed by (dpordomingo)

    Change Log

    • config: fix wildcard handling in RefSpec matching #1160 (novas0x2a)
    • config support the 'rebase' config key for branches #1154 (yelirekim)
    • git: Repository: improve ResolveRevision's Ref lookup path #1146 (novas0x2a)
    • git: Worktree: keep local changes when checkout branch #1145 (linuxerwang)
    • git : allows to create a Remote without a Repository #1142 (EmrysMyrddin)
    • plumbing: format/idxfile, avoid creating temporary buffers to decode integers #1136 (filipnavara)
    • plumbing: format/commitgraph, rename structs/fields to follow the terms #1134 (filipnavara)
    • plumbing: format/commitgraph, clean up error handling #1133 (filipnavara)
    • plumbing: object, add APIs for traversing over commit graphs #1132 (filipnavara)
    • plumbing: format/packfile, Fix data race and resource leak. #1159 (ebardsley)
    • plumbing: format/gitattributes support #1130 (saracen)
    • plumbing: format/commitgraph, add APIs for reading and writing commit-graph files #1128 (filipnavara)
    • plumbing: object/{commit,tag} add EncodeWithoutSignature, Implement #1116 #1127 (sapk)
    • plumbing: format/index perf, buffered reads, reflection removal #1126 (saracen)
    • plumbing: TreeWalker performance improvement, bufio pool for objects #1125 (saracen)
    • plumbing: packfile/scanner, readability/performance improvements, zlib pooling #1124 (saracen)
    • plumbing: packfile, apply small object reading optimization also for delta objects #1121 (filipnavara)
    • plumbing: idxfile, avoid unnecessary building of reverse offset/hash map #1119 (filipnavara)
    • plumbing: object, Fix tag message decoding #1118 (filipnavara)
    • plumbing: object, Create merge-base feature #1097 (dpordomingo)
    • examples: Add merge base command #1096 (dpordomingo)
    • filesystem: ObjectStorage, MaxOpenDescriptors option #1123 (saracen)
    • ssh: leverage proxy from environment #1090 (dweomer)
    • go modules update #1131 (mcuadros)
    Source code(tar.gz)
    Source code(zip)
  • v4.11.0(Mar 9, 2020)

    Nothing very significant in this release but contains a bunch of bug fixing and improvements.

    Change Log

    • git: add Repository.CreateRemoteAnonymous #1094 (niukuo)
    • git: remove potentially duplicate check for unstaged files #1081 (meinto)
    • git: fix goroutine block while pushing a remote #1080 (jfontan)
    • storage/transactional: implement storer.PackfileWriter #1093 (jfontan)
    • plumbing: fix missing error in bfsCommitIterator #1092 (niukuo)
    • plumbing: object, Count stats properly when no new line added at the … #1088 (oleksii-shnyra)
    • plumbing: commit.StatsContext and fix for orphan commit #1115 (mcuadros)
    • plumbing: fix panic in object.Tree.FindEntry #1095 (niukuo)
    • plumbing/cache: check for empty cache list #1076 (jfontan)
    • worktree: allow manual ignore patterns when no .gitignore is available #1070 (fbsb)
    • utils/diff: Increase diffmatchcpatch timeout #1084 (vmarkovtsev)
    Source code(tar.gz)
    Source code(zip)
  • v4.10.0(Mar 9, 2020)

    This release is full of cool stuff, starting with a new EXPERIMENTAL transactional storage implementation, or performance improvements for local remotes, take a look at the changelog:

    Change Log

    • plumbing: commit_walker, ignore missing references/objects on log --all #1067 (ajnavarro)
    • remote: speed up pushes when the "remote" repo is local #1066 (strib)
    • utils: merkletrie, remove Unicode normalization in difftree #1065 (vmarkovtsev)
    • worktree: add sentinel error for non-fast-forward pull #1064 (asv)
    • packfile: get object size correctly for delta objects #1060 (strib)
    • storage: transactional, new storage with transactional capabilities #1006 (mcuadros)
    Source code(tar.gz)
    Source code(zip)
  • v4.9.1(Mar 9, 2020)

    Patch version from 4.9.0, fixing a corner case (https://github.com/src-d/gitbase/pull/688).

    Changelog

    • storage/filesystem: check file object before using cache (#1056)
    Source code(tar.gz)
    Source code(zip)
  • v4.9.0(Mar 9, 2020)

    This new version comes with some new functionality like the new LogOptions.All option that mimics the git log --all done by @kuba--, plus some performance improvements for reading large commit histories implemented by @filipnavara.

    Change Log

    • git: Implement git log --all #1045 (kuba--)
    • git: return better error message when packfile cannot be downloaded #1031 (jfontan)
    • storage/dotgit: use fs capabilitie in setRef #1036 (jfontan)
    • plumbing: format/packfile, performance optimizations for reading large commit histories #963 (filipnavara)
    Source code(tar.gz)
    Source code(zip)
  • v4.8.1(Mar 9, 2020)

  • v4.8.0(Mar 9, 2020)

    This version includes support for a new index extension, the EOIE extension, enabled by default in the upcoming git v2.20. Also includes a bunch of fixes and new features, take a look at the change log.

    Change Log

    • plumbing: format/index: support for EOIE extension #1025 (mcuadros)
    • plumbing: format/packfile, remove unused getObjectData method #1022 (ajnavarro)
    • plumbing: format/packfile, Fix broken "thin" packfile support. Fixes #991 #994 (jpeletier)
    • plumbing: transport/ssh, fix flaky test TestAdvertisedReferencesNotExists. Fixes #969 #1013 (mccurdyc)
    • plumbing: transport/http: improve TokenAuth documentation #1009 (smola)
    • plumbing: transport/http, Add missing host/port on redirect. Fixes #820 #1001 (hairyhenderson)
    • plumbing: ReferenceName constructors #998 (mcuadros)
    • storage/filesystem: Added reindex method to reindex packfiles #1019 (jpeletier)
    • Repository: Fix RefSpec for a single tag. #1015 (fkorotkov)
    • Repository: cleanup after failed clone #1008 (smola)
    • git: enables building on OpenBSD, Dragonfly BSD and Solaris #992 (yuce)
    • remote: use reference deltas on push when the remote server does not … #987 (bashims)
    • examples: PlainClone with Basic Authentication (Password & Access Token) #990 (mccurdyc)
    Source code(tar.gz)
    Source code(zip)
  • v4.7.1(Mar 9, 2020)

    From this release you can us go-git as a go module. Also, this release includes a bunch of fixes in different packages, take a look at the change log

    Change Log

    • all: convert into a Go module #943
    • blame: fix edge case with missing \n in content length causing mismatched length error #986 (mcuadros)
    • repository: improve CheckoutOption.Hash doc #985 (mcuadros)
    • repository: allow open non-bare repositories as bare #984 (mcuadros)
    • repository: use remote name in fetch while clone, Fixes #827 [#828]
    • repository: allow ResolveRevision to resolve annotated tags #772 (novas0x2a)
    • storage: expose Storage cache. #949 (kuba--)
    • storage/filesystem: keep packs open in PackfileIter #962 (jfontan)
    • config: Add test for Windows local paths. Fixes #681 #977 (filipnavara)
    • git: Fix Status.IsClean() documentation #978 (urld)
    • git: use time.IsZero in Prune #974 (u5surf)
    • git: Add tagging support #928 (vancluever)
    • plumbing: object, Add support for Log with filenames. Fixes #826 #979 (gnithin)
    • plumbing: tree, add a Size() method for getting plaintext size #982 (strib)
    • plumbing: improve test for urlencoded user:pass #968 (smola)
    • plumbing: diff, fix fatal: corrupt patch error in unified diff format #932 (distorhead)
    • plumbing: cache, fix potential LRU cache size issue. #958 (kuba--)
    Source code(tar.gz)
    Source code(zip)
  • v4.7.0(Mar 9, 2020)

    Here is a new release of go-git, containing a mix of performance improvements (#929, #942), new features and issue fixing, take a log to the change log.

    Change Log

    • storage/dotgit: add KeepDescriptors option #942 (jfontan)
    • plumbing/storer: add ExclusiveAccess option to Storer #941 (jfontan)
    • plumbing: object, Clamp object timestamps before unix epoch to unix epoch #939 (taruti)
    • config: add commentChar to core config struct #937 (zaquestion)
    • storage/dotgit: search for incoming dir only once #935 (jfontan)
    • storage/dotgit: Remove empty dirs when cleaning with Dir opt. #933 (kuba--)
    • plumbing, storage: add bases to the common cache #929 (jfontan)
    • plumbing/idxfile: object iterators returns entries in offset order #927 (jfontan)
    • plumbing/format: gitignore, fixed an edge case for .gitignore #924 (fkorotkov)
    Source code(tar.gz)
    Source code(zip)
  • v4.6.0(Mar 9, 2020)

    Finally here is a new release of go-git, coming with big performance improvements thanks to the new packfile representation #899 (erizocosmico) and parser #898 (jfontan), speeding up the execution of read operation from 25% to almost a 300% depending on the repository topology.

    Also, this release comes with some new features and bug fixes, take a look at the change log.

    Change Log

    Source code(tar.gz)
    Source code(zip)
  • v4.5.0(Mar 9, 2020)

    This release includes a variety of different changes, some performance improvements for packafile index decoding, but as well as some functions at storage were made public, plus some other fixes and improvements.

    Change Log

    • plumbing: add context to allow cancel on diff/patch computing #874 (smola)
    • utils: diff, skip useless rune->string conversion #873 (smola)
    • Remote.Fetch: error on missing remote reference #870 (mcuadros)
    • packfile: optimise NewIndexFromIdxFile for a very common case #869 (dsymonds)
    • storage/filesystem: avoid norwfs build flag #864 (smola)
    • plumbing/transport: http, Adds token authentication support [Fixes #858] #859 (ebilling)
    • storage: filesystem, make ObjectStorage constructor public #857 (erizocosmico)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.1(Mar 9, 2020)

    Here is a new version of go-git including some memory optimizations by dsymonds and a couple of bug fixes, #480 and #793.

    Change Log

    • plumbing: packfile, Don't copy empty objects. Fixes #840 #856 (kuba--)
    • plumbing: object, adds tree path cache to trees. Fixes #793 #855 (jfontan)
    • dotgit: Move package outside internal. #854 (ajnavarro)
    • config: modules, worktree: Submodule fixes for CVE-2018-11235 #848 (josephvusich)
    • packfile: improve Index memory representation to be more compact #846 (dsymonds)
    • idxfile: optimise allocations in readObjectNames #845 (dsymonds)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.0(Mar 9, 2020)

    New go-git version including a new functionality to support excludes on the Worktree and also a big improvement of performance for repositories with thousands of references.

    Change Log

    • git: remote, Do not iterate all references on update. #833 (jfontan)
    • Worktree: Provide ability to add excludes to worktree #825 (maguro)
    • Fix for "Worktree Add function adds ".git" directory" #815 (kuba--)
    Source code(tar.gz)
    Source code(zip)
  • v4.3.1(Mar 9, 2020)

  • v4.3.0(Mar 9, 2020)

    A small feature release including the new PlainOpenWithOptions function able to locate the .git folder by @mvdan and a basic feature that was missing, the tracking branches on Clone by @TheHipbot

    Change Log

    Implemented enhancements:

    • config: adds branches to config for tracking branches against remotes… #803 (TheHipbot)
    • add PlainOpen variant to find .git in parent dirs #784 (mvdan)
    Source code(tar.gz)
    Source code(zip)
  • v4.2.1(Mar 9, 2020)

  • v4.2.0(Mar 9, 2020)

    After a very busy week, at Git Merge 2018, here is a new release of go-git, doesn't include anything very relevant besides the new Worktree.[AddGlob|RemoveBlob] methods and the new traversal order for Repository.Log done by @ilius

    Changes

    Fixed bugs:

    • Basic Auth: Encode special characters in password #723
    • Plain clone throws error even when repo doesn't exist #755

    Merged pull requests:

    • repository.Log: add alternatives for commit traversal order #771 (ilius)
    • storage/filesystem: optimize packfile iterator #769 (dennwc)
    • Unused params, unused code, make Go tip's vet happy #766 (mvdan)
    • plubming: transport, Escape the user and pswd for endpoint. Fixes #723 #762 (zkry)
    • plumbing: ssh, return error when creating public keys from invalid PEM #759 (mdelillo)
    • blame: Add blame line data #754 (shanedasilva)
    • new methods Worktree.[AddGlob|RemoveBlob] and recursive Worktree.[Add|Remove] #739 (mcuadros)
    Source code(tar.gz)
    Source code(zip)
  • v4.1.1(Mar 9, 2020)

    Maintenance release including purely bug fixes. The only API change is Clone.NoCheckout option #721 beeing added.

    Changes

    Fixed bugs:

    • transport: http, fix services redirecting only info/refs #751 (mcuadros)
    • plumbing: diff, fix crash when a small ending equal-chunk #749 (irias)
    • plumbing: format/packfile, fix panic retrieving object hash. #744 (jfontan)
    • storage/filesystem/shallow: fix error checking #740 (ferhatelmas)
    • plumbing: format/packfile, fix crash with cycle deltas #731 (jfontan)

    Merged pull requests:

    • plumbing: packfile, Add a buffer to crc writer #724 (jfontan)
    • git: added Clone.NoCheckout option #721 (rykov)
    Source code(tar.gz)
    Source code(zip)
  • v4.1.0(Mar 9, 2020)

    Here is a new release of go-git, it's focused on a performance improvement at clone operation with medium to big repositories (bigger than 200mb).

    The clone operation it's now 2x times faster and uses 3x-5x times less memory.

    Changes

    Fixed bugs:

    • config: set default pack window size in config #712 (jfontan)

    Merged pull requests:

    • plumbing: cache, modify cache to delete more than one item to free space #720 (jfontan)
    • plumbing: packfile, clean reconstructed objects outside pack window #716 (jfontan)
    • examples: add branch add/remove example #714 (marwan-at-work)
    Source code(tar.gz)
    Source code(zip)
  • v4.0.0(Mar 9, 2020)

    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.

    After almost 18 months of development, more than +700 commits, and 15 release candidates we are pleased to release the v4 covering almost all the commonly used git functionalities.

    The project license has changed to Apache License Version 2.0 and Developer Certificate of Origin. Also now provide Contributing Guidelines in order to make easier contribute to the project.

    Stable API

    The API is considered stable in all the functions reachable from the main package. This means that the plumbing structs and functions from plumbing package that are being used as arguments or returned by functions in the main package are stable too. Plumbing structures used under the hood may change in following releases but in ways that won't break compatibility.

    Changes

    Fixed bugs:

    • panic in object.getFileStatsFromFilePatches() for commits updating submodules: both from and to are nil #654
    • RemoveReference doesn't always work #648
    • Checking out over https fails #623
    • git commit -a should not refer to the storage but to the filesystem #571
    • SIGSEGV in fillREFDeltaObjectContent #568
    • Rare SIGSEGV in fillREFDeltaObjectContent #682
    • repo.Reference(plumbing.ReferenceName("refs/remotes/origin/branch"), true) results in "reference not found" error #676
    • Commit Modified Lines #622
    • PlainClone not fully populating tree on Windows #389

    Merged pull requests:

    • License upgrade, plus code of conduct and contributing guidelines #680 (mcuadros)
    • Worktree.Grep() support multiple patterns and pathspecs #695 (darkowlzz)
    • Worktree, add Grep() method for git grep #686 (darkowlzz)
    • Worktree, add Clean() method for git clean #675 (darkowlzz)
    • storage: filesystem, add support for git alternates #663 (darkowlzz)
    • storage: add new functions for garbage collection #669 (strib)
    • fix Repository.ResolveRevision for branch and tag #660 (antham)
    • *: update to go-billy.v4 and go-git-fixtures.v3 #655 (mcuadros)
    • storage: dotgit, handle refs that exist in both packed-refs and a loose ref file #666 (strib)
    • storage: dotgit, remove ref cache for packed refs #651 (erizocosmico)
    • utils: merkletrie, filesystem fix symlinks to dir #640 (dimonomid)
    • config: support a configurable, and turn-off-able, pack.window #587 (strib)
    • Remote, fix a range loop can break in advance #641 (sunfishgao)
    • Remote, support for non-force, fast-forward-only fetches #665 (strib)
    • Remote, add the last 100 commits for each ref in haves list #610 (strib)
    • Remote, add support for ls-remote #609 (darkowlzz)
    • Remote, iterate over references only once #580 (erizocosmico)
    • Worktree.Add, Support Add deleted files, fixes #571 #577 (grunenwflorian)
    • plumbing: cache, enforce the use of cache in packfile decoder #698 (jfontan)
    • plumbing: packp/capability, skip argument validations for unknown capabilities #626 (orirawlings)
    • plumbing: packfile, fix DecodeObjectAt when Decoder has type #646 (mcuadros)
    • plumbing: packfile, delete index maps from memory when no longer needed #632 (strib)
    • plumbing: packfile, use buffer pool for diffs #631 (strib)
    • plumbing: packfile, improve delta reutilization #697 (ajnavarro)
    • plumbing: object, add Stats() to Commit #613 (darkowlzz)
    • plumbing: object, add support for signed commits #616 (darkowlzz)
    • plumbing: object/tag, add signature and verification support #658 (darkowlzz)
    • plumbing: object, new Commit.Verify method #653 (darkowlzz)
    • plumbing: object, do not eat error on tree decode #652 (ferhatelmas)
    • plumbing: object: patch, fix stats for submodules (fixes #654) #677 (krylovsk)
    • plumbing: transport, add port to SCP Endpoints #608 (balkian)
    • plumbing: transport/http, Close http.Body reader when needed #657 (ajnavarro)
    • plumbing: transport/ssh, check .ssh/config for host and port overrides; fixes #629 #687 (smithrobs)
    • plumbing: transport, converts Endpoint interface into a struct #650 (mcuadros)
    • plumbing: transport, made public all the fields and standardized AuthMethod #649 (mcuadros)
    • plumbing: revlist, do not revisit ancestors as long as all branches are visited #588 (erizocosmico)
    • plumbing: the commit walker can skip externally-seen commits #586 (strib)
    • plumbing: packfile, improve performance of delta generation #582 (erizocosmico)
    • plumbing: object, commit.Parent() method #534 (josharian)
    Source code(tar.gz)
    Source code(zip)
  • v4.0.0-rc15(Mar 9, 2020)

    Fixed bugs:

    • Worktree.Clone can't checkout commit pointed to by tag, but Git works #574
    • Worktree.Checkout:Force bug? #435
    • Worktree Checkout and Reset call to fetch operations on submodules #415

    Merged pull requests:

    • packfile: improve performance a little by reducing gc pressure #578 (erizocosmico)
    • Repository.Clone added Tags option, and set by default AllTags #576 (mcuadros)
    • Add sideband support for push #573 (orirawlings)
    • Worktree.Reset refactor and Soft, Merge, Hard and Mixed modes #572 (mcuadros)
    • dotgit: avoid duplicated references returned by Refs #569 (erizocosmico)
    Source code(tar.gz)
    Source code(zip)
Owner
go-git
A highly extensible Git implementation in pure Go.
go-git
Git with a cup of tea, painless self-hosted git service

Gitea - Git with a cup of tea View the chinese version of this document Purpose The goal of this project is to make the easiest, fastest, and most pai

Gitea 32.3k Sep 18, 2022
A Git RPC service for handling all the git calls made by GitLab

Quick Links: Roadmap | Want to Contribute? | GitLab Gitaly Issues | GitLab Gitaly Merge Requests | Gitaly is a Git RPC service for handling all the gi

null 1 Nov 13, 2021
A simple cli tool for switching git user easily inspired by Git-User-Switch

gitsu A simple cli tool for switching git user easily inspired by Git-User-Switch Installation Binary releases are here. Homebrew brew install matsuyo

Masaya Watanabe 202 Sep 15, 2022
Removes unnecessarily saved git objects to optimize the size of the .git directory.

Git Repo Cleaner Optimizes the size of the .git directory by removing all of the files that are unnecessarily-still-saved as part of the git history.

Omar Yasser 2 Mar 24, 2022
Gum - Git User Manager (GUM) - Switch between git user profiles

Git User Manager (GUM) Add your profile info to config.yaml Build project: go bu

Mehmet Tevfik YÜKSEL 6 Feb 14, 2022
Git-now-playing - Git commits are the new AIM status messages

git-now-playing git-now-playing is an attempt to bring some of the panache of th

Paddy 1 Apr 4, 2022
Implementation of git internals from scratch in Go language

This project is part of a learning exercise to implement a subset of "git" commands. It can be used to create and maintain git objects, such as blobs, trees, commits, references and tags.

Shyamsunder Rathi 36 Aug 30, 2022
Gogs is a painless self-hosted Git service

Gogs - A painless self-hosted Git service 简体中文 ?? Vision The Gogs (/gɑgz/) project aims to build a simple, stable and extensible self-hosted Git servi

Gogs 40.9k Sep 21, 2022
commit/branch/workdir explorer for git

gitin gitin is a commit/branch/status explorer for git gitin is a minimalist tool that lets you explore a git repository from the command line. You ca

Ibrahim Serdar Acikgoz 1.8k Sep 22, 2022
A command-line tool that makes git easier to use with GitHub.

hub is a command line tool that wraps git in order to extend it with extra features and commands that make working with GitHub easier. For an official

GitHub 22k Sep 15, 2022
A tool to monitor git repositories and automatically pull & push changes

git-o-matic A tool to monitor git repositories and automatically pull & push changes Installation Packages & Binaries Arch Linux: gitomatic Binaries f

Christian Muehlhaeuser 1k Sep 16, 2022
SQL interface to git repositories, written in Go. https://docs.sourced.tech/gitbase

gitbase gitbase, is a SQL database interface to Git repositories. This project is now part of source{d} Community Edition, which provides the simplest

source{d} 2k Sep 16, 2022
Fast and powerful Git hooks manager for any type of projects.

Lefthook The fastest polyglot Git hooks manager out there Fast and powerful Git hooks manager for Node.js, Ruby or any other type of projects. Fast. I

Abroskin Alexander 2.4k Sep 25, 2022
A Simple and Comprehensive Vulnerability Scanner for Container Images, Git Repositories and Filesystems. Suitable for CI

A Simple and Comprehensive Vulnerability Scanner for Containers and other Artifacts, Suitable for CI. Abstract Trivy (tri pronounced like trigger, vy

Aqua Security 14k Sep 25, 2022
go mod vendor lets you check in your dependencies to git, but that's both bloaty (for developers) and tedious (remembering to update it).

go-mod-archiver Afraid of being unable to build historical versions of your Go program? go mod vendor lets you check in your dependencies to git, but

Tailscale 83 Aug 28, 2022
Quickly clone git repositories into a nested folders like GOPATH.

cl cl clones git repositories into nested folders like GOPATH and outputs the path of the cloned directory. Example: cl https://github.com/foo/bar Is

Felix Geisendörfer 12 Jun 2, 2022
Switch between your git profiles easily

Git Profile Switcher Switch between your git profiles easily Install With Brew brew install theykk/tap/git-switcher With golang go get github.com/the

Kaan Karakaya 213 Sep 20, 2022
Store private data inside a git repository.

git-private lets you store private data inside a git repo. A common use case is protecting files containing API keys et.c.

Erik Agsjö 9 Jul 25, 2022
Simple git hooks written in go that installs globally to your machine

Go-hooks Simple git hooks written in go that installs globally to your machine Install curl -fsSL

Vadim Makerov 1 Aug 23, 2022