Maison > développement back-end > Golang > le corps du texte

Importer le projet Go depuis le référentiel privé Gilab à l'aide de ssh : révision inconnue

WBOY
Libérer: 2024-02-09 11:24:08
avant
1011 Les gens l'ont consulté

使用 ssh 从私有 gilab 存储库导入 go 项目:未知修订版

l'éditeur php Xigua vous présentera comment utiliser SSH pour importer une révision inconnue d'un projet Go à partir d'un référentiel GitLab privé. La connexion à GitLab via SSH vous permet d'importer facilement des projets dans votre environnement local pour les modifier et les développer. Cet article expliquera en détail chaque étape du processus d'importation afin que les lecteurs puissent terminer l'opération facilement. Avant de continuer, assurez-vous que Git and Go est installé et que vous avez créé un référentiel privé sur GitLab. commençons!

Contenu de la question

J'essaie d'importer un projet go à partir d'un référentiel gitlab privé et auto-hébergé en utilisant ssh. Lorsque j'essaie de faire cela, j'obtiens l'erreur suivante.

Sortie

kbacon@kbacons-macbook-pro bbz % go get -x gitlab.wtf.notworking/bbq/tools@latest
# get https://gitlab.wtf.notworking/bbq/tools?go-get=1
# get https://gitlab.wtf.notworking/bbq/tools?go-get=1: 200 ok (0.413s)
mkdir -p /users/kbacon/go/pkg/mod/cache/vcs # git3 https://gitlab.wtf.notworking/bbq/tools.git
# lock /users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179.lock# /users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179 for git3 https://gitlab.wtf.notworking/bbq/tools.git
cd /users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179; git tag -l
0.013s # cd /users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179; git tag -l
cd /users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179; git ls-remote -q origin
0.020s # cd /users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179; git ls-remote -q origin
# get https://gitlab.wtf.notworking/bbq/tools.git
# get https://gitlab.wtf.notworking/bbq/tools.git: 200 ok (0.186s)
go: gitlab.wtf.notworking/bbq/[email protected]: reading gitlab.wtf.notworking/bbq/tools/go.mod at revision v1.0.0: unknown revision v1.0.0
Copier après la connexion

.gitconfig

[user]
        name = kbacon
        email = [email protected]
[url "[email protected]/"]
        insteadof = https://gitlab.wtf.notworking/
Copier après la connexion

Aller au fichier mod

module bbz
go 1.14
require (
    gitlab.wtf.notworking/bbq/tools v1.0.0
)
Copier après la connexion

dépôt gitlab

Le dépôt gitlab a un projet avec une balise release v1.0.0

L'adresse que j'avais utilisée pour cloner

ssh://[email protected]:2224/bbq/tools.git
Copier après la connexion

fichier de configuration ssh

host gitlab.wtf.notworking
    user [email protected]
    hostname gitlab.wtf.notworking
    identityfile ~/.ssh/company_gitlab # path to private key
    addkeystoagent yes
Copier après la connexion

Utilisez ce .gitconfig : .gitconfig

[user]
        name = kbacon
        email = [email protected]
[url "[email protected]:2224/"]
        insteadof = https://gitlab.wtf.notworking/
Copier après la connexion

Ensuite, la commande go get me demandera mon mot de passe, mais elle doit utiliser ssh. Pourquoi me demande-t-on mon mot de passe ?

kbacon@kbacons-MacBook-Pro bbz % go get -x gitlab.wtf.notworking/bbq/tools@latest
# get https://gitlab.wtf.notworking/bbq/tools?go-get=1
# get https://gitlab.wtf.notworking/bbq/tools?go-get=1: 200 OK (0.424s)
mkdir -p /Users/kbacon/go/pkg/mod/cache/vcs # git3 https://gitlab.wtf.notworking/bbq/tools.git
# lock /Users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179.lock# /Users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179 for git3 https://gitlab.wtf.notworking/bbq/tools.git
cd /Users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179; git tag -l
0.030s # cd /Users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179; git tag -l
cd /Users/kbacon/go/pkg/mod/cache/vcs/3bd57e1dd1ed847c1ac192f16c5f67541135ce037a175de23ec5fb5051d10179; git ls-remote -q origin
[email protected]'s password:
Copier après la connexion

Solution de contournement

Si vous utilisez ssh, l'URL est / 而不是 :,您的 .gitconfig elle devrait être :

[url "ssh://<a href="https://www.php.cn/link/89fee0513b6668e555959f5dc23238e9" class="__cf_email__" data-cfemail="10777964507779647c71723e6764763e7e7f64677f627b797e77">[email&#160;protected]</a>:2224/"]
        insteadof = https://gitlab.wtf.notworking/
Copier après la connexion

Utilisez ":"

[url "<a href="https://www.php.cn/link/89fee0513b6668e555959f5dc23238e9" class="__cf_email__" data-cfemail="e4838d90a4838d90888586ca939082ca8a8b90938b968f8d8a83">[email&#160;protected]</a>:2224:"]
        insteadof = https://gitlab.wtf.notworking/
Copier après la connexion

Dans votre fichier de configuration ssh, assurez-vous d'utiliser le compte de service git et non vos entrées de connexion, de port et d'hôte personnalisé :

host gitlab-wtf
    user git
    hostname gitlab.wtf.notworking
    identityfile ~/.ssh/company_gitlab # path to private key
    addkeystoagent yes
    port 2224
Copier après la connexion

De cette façon, vous pouvez utiliser :

[url "ssh://gitlab-wtf/"]
        insteadof = https://gitlab.wtf.notworking/
Copier après la connexion

Pas plus git@:2224.

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

source:stackoverflow.com
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!