3

将 github 设为私有仓库

 1 year ago
source link: https://studygolang.com/articles/28719?fr=sidebar
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

将 github 设为私有仓库

cpath_9d7a · 2020-05-17 22:32:44 · 799 次点击 · 预计阅读时间 1 分钟 · 大约8小时之前 开始浏览    
这是一个创建于 2020-05-17 22:32:44 的文章,其中的信息可能已经有所发展或是发生改变。

将 github 设为私有仓库

<第一步> : 生成token 「如果不是项目的构建者,问项目负责人获取」


https://github.com/settings/tokens/new

<第二步> : token 设置到请求头中

git config --global http.extraheader "PRIVATE-TOKEN:YOUR_PRIVATE_TOKEN"

<第三步> : 配置git将请求从ssh转换为http

#全局替换拉取域下的所有包
 
git config --global url."[email protected]:xxxx".insteadOf "https://github.com/xxxx"

#全局替换拉取域下的单个包,使用“全局替换拉取域下的所有包” 可以不设置
git config --global url."[email protected]:xxx/xxxxxxx.git".insteadOf "https://github.com/xxx/xxxxxxx.git"

<第四步> : 指定域名为私有仓库

go env -w GOPRIVATE=github.com

<第五步> : 检查配置

执行 cat ~/.gitconfig

[http]
    extraheader = PRIVATE-TOKEN:xxxxx

[url "[email protected]:xxxxx"]
    insteadOf = https://github.com/xxxx

执行 go env

GOPRIVATE="github.com"

确认配置成功

<第六步> : 测试配置结果

执行
go mod tidy        


显示
go: finding module for package github.com/xxx
go: found github.com/xx/xxx/inits in github.com/xxx/xxx v1.0.1

恭喜你设置成功啦~

https://golang.org/doc/faq#git_https


https://segmentfault.com/a/1190000021127791?utm_source=tag-newest


https://www.jianshu.com/p/ca4404512cf3


有疑问加站长微信联系(非本文作者)

280

本文来自:简书

感谢作者:cpath_9d7a

查看原文:将 github 设为私有仓库

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK