alex-shpak/gitname

Configure default for user when there is no remote

Closed this issue · 4 comments

Occasionally I need to start a repository locally and I don't have or don't want to have a remote. This does not play nice with the safety provided by unsetting the global user as described here.

Would be cool to configure a default user for gitname, so it can setup local config even when there is no remote. Maybe with some -f (force) flag and warning in the default mode. E.g.

$ git init
$ gitname
2020/04/07 18:19:38 Remote 'origin' not found. Use gitname -f to use default user.
$ gitname -f
2020/04/07 18:26:11 Committing as John Doe <john.doe@example.com>

Sup!
Maybe option would be to specify remote 'key' by flag? Like gitname --force github.com which will pick settings for that domain.

Actually maybe it can be an optional argument gitname github.com

Later sounds good! The semantics would be for gitname to set configuration based on the provided config key or guess from origin remote if not set.

And then it is up to the user to setup something like:

// .gitconfig
[user "local"]
	name = John Doe
	email = john.doe@example.com
$ gitname local

v4 has been released.

Works like a charm!

Maybe update --help message as well?

$ gitname --help
Usage of gitname:
  -q	Quiet mode
  -remote string
    	Specify git remote, defaults to 'origin' (default "origin")