git & go get

git

  1. 错误 01: git pull
error: cannot lock ref 'refs/remotes/origin/bugfix/remove_unused_log': 'refs/remotes/origin/bugfix' exists; cannot create 'refs/remotes/origin/bugfix/remove_unused_log'
From [gitlab.xxxx.com](http://gitlab.xxxx.com/):backend/live-campaign
! [new branch]        bugfix/remove_unused_log -> origin/bugfix/remove_unused_log  (unable to update local ref)
87b5ad5c..4afbf8fe  testing/1228             -> origin/testing/1228

删掉远程分支 testing/1228, 本地执行 git fetch --prune

  1. 错误 02: go get xxxx
go: [gitlab.xxxxx.com/backend/live-medal/_proto@v1.0.51-0.20210616102043-111161cafa36:](http://gitlab.xxxxx.com/backend/live-medal/_proto@v1.0.51-0.20210616102043-111161cafa36:) invalid pseudo-version: git fetch -f [https://gitlab.xxxxx.com/backend/live-medal.git](https://gitlab.xxxxx.com/backend/live-medal.git) refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /Users/lixingliang/go/pkg/mod/cache/vcs/2c2ff527fe76e1bac601f29f1308f5a6d70182f2daee5d408b90e6d0de343a2e: exit status 1:
From [gitlab.p1staff.com](http://gitlab.xxxxx.com/):backend/live-medal
* [new branch]        bugfix/hier    -> bugfix/hier
* [new branch]        bugfix/remove  -> bugfix/remove
error: cannot lock ref 'refs/heads/testing/210608': 'refs/heads/testing' exists; cannot create 'refs/heads/testing/210608'
! [new branch]        testing/210608 -> testing/210608  (unable to update local ref)
error: some local refs could not be updated; try running
'git remote prune [https://gitlab.xxxxx.com/backend/live-medal.git](https://gitlab.xxxxx.com/backend/live-medal.git)' to remove any old, conflicting branches

解决: rm -rf $GOPATH/pkg/mod/gitlab.xxxxx.com/backend/live-medal, 然后重新 go get ./...

再不行: rm -rf $GOPATH/pkg/mod/cache/vcs/, 然后重新 执行 go get ./...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用 `go get` 命令从私有仓库中获取包,需要进行以下步骤: 1. 在你的私有仓库中创建一个访问令牌或者 SSH 密钥,并将其添加到你的 Git 提供商中。这一步根据你使用的 Git 提供商(如 GitHub、GitLab、Bitbucket 等)而有所不同,可以参考对应的文档进行操作。 2. 将访问令牌或者 SSH 密钥添加到你的本地 Git 配置中。如果你使用的是访问令牌,可以执行以下命令: ``` git config --global github.token <your_token> ``` 如果你使用的是 SSH 密钥,可以将其添加到 `~/.ssh/config` 文件中,如下所示: ``` Host github.com HostName github.com IdentityFile ~/.ssh/id_rsa ``` 其中 `IdentityFile` 指定了你的 SSH 密钥路径。 3. 使用 `go get` 命令获取包,并在 URL 前加上访问令牌或者 SSH 协议,如下所示: ``` go get git@github.com:<username>/<repo>.git ``` 或者: ``` go get https://<token>@github.com/<username>/<repo>.git ``` 其中 `<token>` 指代访问令牌,`<username>` 和 `<repo>` 分别指代 Git 仓库的用户名和仓库名。 注意:如果你使用的是 HTTPS 协议,需要将 `<token>` 编码,否则会出现错误。可以使用以下命令进行编码: ``` echo -n "<token>" | base64 ``` 然后将编码后的字符串替换 `<token>`。 4. 等待 `go get` 命令完成,就可以在你的项目中使用私有仓库中的包了。 需要注意的是,私有仓库中的包可能会受到 Git 提供商的限制。例如,GitHub 的免费账户只能创建公共仓库,如果要创建私有仓库需要购买付费版。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值