Skip to content

Commit

Permalink
add mod and add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sadayuki-matsuno committed Apr 12, 2020
1 parent a1c704b commit 07437e8
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 3 deletions.
68 changes: 67 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,68 @@
# git-helper-substitute
git credential helper, which switches git credentials for the organization

git credential helper, which switches git credentials for the username/organization.

If you are using multiple github accounts, it uses the information of the organization to determine the authentication information.

# Installation

```
go get -u github.com/sadayuki-matsuno/git-credential-substitute
```

# Features

- Store credentials for each github organization and use the appropriate credentials
- If you're in the git directory, it will determine the credential based on the organization information in the origin and use it.
- If not applicable to any organization, the default credentials are used.

# Quick Start

- install git-credential-substitute

```
go get -u github.com/sadayuki-matsuno/git-credential-substitute
```

- make .git-secret.json

```
cat $HOME/.git-secret.json
{
"another-organization": {
"username": "another-github-username",
"password": "xxxxxxxxxxxxxxxxxxxxxxx"
},
"default": {
"username": "sadayuki-matsuno",
"password": "xxxxxxxxxxxxxxxx"
}
}
```

- change git-credential-helper

```
git config --global credential.helper substitute
```

- check your git-credential-healper

```
git config --show-origin --get credential.helper
file:$HOME/.gitconfig substitute
```

**If you see other helpers, you need to remove their settings or they may not work properly.**

- All settings are complete. All that's left to do is to use the git command as usual

# Debug

To check which directory uses which credentials, try running `git-credential-substitute` in the target directory.

# Author

sadayuki-matsuno
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/sadayuki-matsuno/git-credential-substitute

go 1.13

require github.com/urfave/cli/v2 v2.2.0
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2 changes: 1 addition & 1 deletion internal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"path"
"path/filepath"

"gopkg.in/urfave/cli.v2"
"github.com/urfave/cli/v2"
)

var defaultKey = "default"
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"

"github.com/sadayuki-matsuno/git-credential-substitute/internal"
"gopkg.in/urfave/cli.v2"
"github.com/urfave/cli/v2"
)

func main() {
Expand Down

0 comments on commit 07437e8

Please sign in to comment.