On 5/22/19 5:35 AM, Gert van Dijk wrote:
> On Wed, May 22, 2019 at 2:13 PM RAMANA REDDY <
ramanar...@gmail.com
> <mailto:
ramanar...@gmail.com>> wrote:
>
> When I clone a repo with username, it works fine
>
> git clone
> ssh://*username*@
gerrithost.net:29418/MyRepo
> <
http://gerrithost.net:29418/MyRepo>
> <
http://gerrithost.net:29418/MyRepo>
>
> This works in some of the laptops, but not in every laptop. What
> is the setting I need to do for the same to make it work on other
> laptops?
>
> I tried adding a global config with username and email
> (.gitconfig). This doesn't work.
>
>
> It really depends on the platform that you're using. I'm going to assume
> Linux here with OpenSSH client being used by git helpers. /Moreover,
> this is not specific to Gerrit, but is a plain git client configuration./
>
> What I personally like to do is creating an OpenSSH client configuration
> (e.g. in ~/.ssh/config or globally in /etc/ssh/ssh_config) in which I
> specify the servers I connect to frequently. Example:
>
> Host mygerrit1
> Hostname gerrit.corp.mycompany.tld
> # custom username for this Gerrit host
> Username gert.vandijk
> Port 29418
>
> Host mygerrit2
> Hostname review.mydomain.tld
> # Custom SSH port for this one
> Port 12345
>
> # Default for all hosts:
> Host *
> User gertvdijk
I do something similar but instead of making shortcuts, I do the following:
--[cut]--
# Standard LF hosted gerrit systems
Host gerrit.*.* gerrit-new.*.*
Port 29418
User agrimberg
--[/cut]--
This does mean that I have to fully specify a particular hostname in my
cloning or ssh API operations, but it means I don't have to go and add a
section for any gerrit system unless they aren't named in a standard
fashion.
For a gerrit that follows the same host syntax that have a different
port or username, I can add specific overrides before the more generic
one in the file.
> After which 'mygerrit1' and 'mygerrit2' have become shortcuts available
> in all applications using OpenSSH client libraries, including git on
> Linux, e.g.:
>
> $ git clone ssh://mygerrit2/MyRepo
>
> Also when working with SSH commands to Gerrit, such as query:
>
> $ ssh mygerrit2 gerrit version
>
> I personally really like the OpenSSH client configuration approach,
> because I use plain SSH a lot too and like to have convenient shortcuts
> without having to specify all options on the command line every time.
>
> HTH
>
> <mailto:
repo-discuss...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/repo-discuss/CAFT%2BaqLGv1mkekZ%3D0zitLG_MkNT6ezXVJjJ9YO9rcZxNVSH87A%40mail.gmail.com
> <
https://groups.google.com/d/msgid/repo-discuss/CAFT%2BaqLGv1mkekZ%3D0zitLG_MkNT6ezXVJjJ9YO9rcZxNVSH87A%40mail.gmail.com?utm_medium=email&utm_source=footer>.