Heim  >  Artikel  >  Backend-Entwicklung  >  Go-Projekt aus privatem Gilab-Repository mit ssh importieren: unbekannte Revision

Go-Projekt aus privatem Gilab-Repository mit ssh importieren: unbekannte Revision

WBOY
WBOYnach vorne
2024-02-09 11:24:08983Durchsuche

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

php-Editor Xigua zeigt Ihnen, wie Sie mit SSH eine unbekannte Revision eines Go-Projekts aus einem privaten GitLab-Repository importieren. Durch die Verbindung mit GitLab über SSH können Sie Projekte zur Änderung und Entwicklung einfach in Ihre lokale Umgebung importieren. In diesem Artikel wird jeder Schritt des Importvorgangs ausführlich erläutert, damit die Leser den Vorgang problemlos abschließen können. Bevor Sie fortfahren, stellen Sie sicher, dass Sie Git and Go installiert und ein privates Repository auf GitLab erstellt haben. Lasst uns beginnen!

Frageninhalt

Ich versuche, ein Go-Projekt mit SSH aus einem privaten und selbstgehosteten Gitlab-Repository zu importieren. Wenn ich das versuche, erhalte ich die folgende Fehlermeldung.

Ausgabe

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

.gitconfig

[user]
        name = kbacon
        email = [email protected]
[url "[email protected]/"]
        insteadof = https://gitlab.wtf.notworking/

Gehe zur Mod-Datei

module bbz
go 1.14
require (
    gitlab.wtf.notworking/bbq/tools v1.0.0
)

Gitlab-Repository

Das Gitlab-Repository verfügt über ein Projekt mit Release-Tag v1.0.0

Die Adresse, die ich geklont habe

ssh://[email protected]:2224/bbq/tools.git

SSH-Konfigurationsdatei

host gitlab.wtf.notworking
    user [email protected]
    hostname gitlab.wtf.notworking
    identityfile ~/.ssh/company_gitlab # path to private key
    addkeystoagent yes

Verwenden Sie diese .gitconfig: .gitconfig

[user]
        name = kbacon
        email = [email protected]
[url "[email protected]:2224/"]
        insteadof = https://gitlab.wtf.notworking/

Dann fragt der go get-Befehl nach meinem Passwort, aber es sollte ssh verwenden. Warum werde ich nach meinem Passwort gefragt?

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:

Workaround

Wenn Sie SSH verwenden, lautet die URL / 而不是 :,您的 .gitconfig, sie sollte lauten:

[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/

Verwenden Sie „:“

[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/

Stellen Sie in Ihrer SSH-Konfigurationsdatei sicher, dass Sie das Dienstkonto git verwenden und nicht Ihre Anmelde-, Port- und benutzerdefinierten Hosteinträge:

host gitlab-wtf
    user git
    hostname gitlab.wtf.notworking
    identityfile ~/.ssh/company_gitlab # path to private key
    addkeystoagent yes
    port 2224

Auf diese Weise können Sie Folgendes verwenden:

[url "ssh://gitlab-wtf/"]
        insteadof = https://gitlab.wtf.notworking/

Nicht mehr git@:2224.

Das obige ist der detaillierte Inhalt vonGo-Projekt aus privatem Gilab-Repository mit ssh importieren: unbekannte Revision. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Dieser Artikel ist reproduziert unter:stackoverflow.com. Bei Verstößen wenden Sie sich bitte an admin@php.cn löschen