Use gitconfig values in Golang.
Branch: master
Clone or download
Latest commit 6411ba1 May 5, 2015
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Sep 8, 2014 v0.1.2 Mar 28, 2015
LICENSE typo Dec 15, 2014 Update Mar 28, 2015
gitconfig.go Add type ErrNotFound May 5, 2015
gitconfig_test.go Add GithubUser getter Mar 25, 2015
helpers_test.go Set include file by absolute path Oct 28, 2014


GitHub release Wercker Coveralls MIT License Go Documentation

go-gitconfig is a pacakge to use gitconfig values in Golang.

Sometimes you want to extract username or its email address implicitly in your tool. Now most of developer use git, so we can use its configuration variables. go-gitconfig is for that.


If you want to use git user name defined in ~/.gitconfig:

username, err := gitconfig.Username()

Or git user email defined in ~/.gitconfig:

email, err := gitconfig.Email()

Or, if you want to extract origin url of current project (from .git/config):

url, err := gitconfig.OriginURL()

You can also extract value by key:

editor, err := gitconfig.Global("core.editor")
remote, err := gitconfig.Local("branch.master.remote")

See more details in document at


To install, use go get:

$ go get -d


These packages have many features to use git from golang. go-gitconfig is very simple alternative and focus to extract information from gitconfig. go-gitconfig is used in tcnksm/ghr.


  1. Fork (
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create new Pull Request