Next: , Previous: , Up: Getting Started   [Contents][Index]


2.2 Setting the Username

Ghub needs to know your username, which you use on the host that you want it to connect to. For each host a different Git variable has to be set, to specify the username on that host. More than one variable is needed, because you might use different usernames on different hosts.

Setting your Github.com Username

To inform Ghub about your "github.com" username do this:

git config --global github.user USERNAME

If you need to identify as another user in a particular repository, then you have to set that variable locally:

cd /path/to/repo
git config --local github.user USERNAME

Setting your Gitlab.com Username

To inform Ghub about your "gitlab.com" username do this:

git config --global gitlab.user USERNAME

If you need to identify as another user in a particular repository, then you have to set that variable locally:

cd /path/to/repo
git config --local gitlab.user USERNAME

Make sure you use the correct USERNAME for this forge/host. It might not be the same as on "github.com"!

Setting your Github Enterprise Username

For Github Enterprise instances you have to specify where the API can be accessed and a different variable has to be used to set the username.

For example if the API is available at https://example.com/api/v3, then you should do this:

git config --global github.example.com/api/v3.user USERNAME

Make sure you use the correct USERNAME for this instance. It might not be the same as on "github.com"!

Doing this only tells Ghub who you are on this host, additionally you have to tell Ghub which repositories are connected to that forge/host, like so:

cd /path/to/repo
git config --local github.host example.com/api/v3

Setting your Username for Other Hosts and/or Forges

To inform Ghub about your username on HOST (a FORGE instance) do this:

git config --global FORGE.HOST.user USERNAME

FORGE can be one of bitbucket, gitea or gogs. It can also be github or gitlab; but if that is the case, then you should look at the preceding sections instead, which discuss these cases specifically.

HOST identifies the instance. This actually points at the top-level endpoint of the API and may contain path components, e.g.: example.com/api.

If you need to identify as another user in a particular repository, then you have to set that variable locally:

cd /path/to/repo
git config --local FORGE.HOST.user USERNAME

Next: Creating and Storing a Token, Previous: Basic Concepts, Arguments and Variables, Up: Getting Started   [Contents][Index]