Github copilot - 01 如何注册激活插件
前言
群里很多同学都在说没用过 copilot ,还有各种安装困惑的。
本文学习如何下载并安装 Github copilot 插件,提高您的编程效率。
关于 copilot 的使用技巧将会在后续文章和大家做讨论。
Github copilot 插件安装教程。
Copilot 介绍
Copilot是由OpenAI和GitHub团队联合开发的一种人工智能代码生成工具。它使用了大规模的自然语言处理和机器学习技术,可以根据用户的输入,自动生成高质量的代码片段,从而帮助程序员提高编程效率。Copilot可以在多种编程语言中生成代码,包括Python、JavaScript、Go、Ruby等等。它可以作为一个GitHub插件,在GitHub上直接与代码库集成,以便开发者更快地编写代码。Copilot的出现在一定程度上改变了人们对于人工智能在软件开发中的应用方式,被视为是一种可行的解决方案。
前置条件
- 科学文明的上网
- 你有一个 github 账号
步骤
第一步:申请 copilot 服务
进入首页
https://github.com/features/copilot/
![image-20230323224805264](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/2c3deceb6abd56f85910c13805bbf670.png)
申请加入
https://github.com/github-copilot/signup
大部分人看到这个界面, 绑定支付方式后 60 天免费用,你可以在第 59 天关闭付款。
![image-20230323230055521](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/204000dc3a4280132d1a079f999c3789.png)
有些人对github有贡献的,会直接免费试用。
可能是 star >= 500,也许是参与了优秀项目,这个算法我确定。
![image-20230323230309409](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/842d47a6844093a70a84b6ba46caaa18.png)
你也可以用学生认证方式免费使用
https://education.github.com/globalcampus/student
验证你的学生身份
建议你注册一个全新的 github 账号来走这个流程,规避政策风险
![image-20230324064443753](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/363ad89b7d4ee2ea6e5c2e5594a525e9.png)
验证流程
![image-20230324065308031](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/c2ce5cdeb3b157778ccae8cadc1aade5.png)
第二步:安装 copilot 插件
在VS Code中,打开扩展商店并搜索“Github Copilot”。选择适当的插件后,点击“Install”按钮进行安装;
注意下载的插件是 github 官方的。
![image-20230323230718096](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/3b54d23411bf009389f17b2d23dd1026.png)
在Android Studio中,打开插件市场并搜索“Github Copilot”。选择适当的插件后,点击“Install”按钮进行安装。
![image-20230323230959297](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/a024f7d2b8200683c9ed519acb85bf9b.png)
第三步:配置 github 账号
在VS Code中,点击左下角的用户图标,选中 “使用 GitHub 登录以使用 GitHub Copilot”
![image-20230323232059750](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/ace504faf279e0d991de68927d1e61af.png)
在Android Studio中,在设置面板中 打开 github 选项页,添加一个已有账号。
登录方式选 "Log in with token ..."
![image-20230323233121226](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/7477145e9f2278e602903c01c293ff0b.png)
点击 Generate 生成按钮
![image-20230323233233047](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/d3e9be95e8dcc541d3404ac3dc7bbe2e.png)
选下过期时间 , 这里我自定义 1 年后过期
![image-20230323233426262](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/ed64dbc29e2fb66a2dfbe4e5e6c1245b.png)
生成 token
![image-20230324000902932](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/ce8202c9048586315c333c50c0a2a765.png)
复制 token
![image-20230324000949946](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/e4c2fbb7a372c8c4805dafba7b234951.png)
输入你的 token 保存
![image-20230323234513360](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/c7ff8b9ceb8b9abb958feed7c788ec43.png)
登录账号
![image-20230324092852658](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/0ef364162b7c956467f3d0fa47d9ff1f.png)
如果有设备验证码,输入即可
![设备代码复制和打开的屏幕截图](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/28ca5f4b6a7e13cd5ab23e1b983e5253.png)
最后:输入提示
在VS Code中, 开启提示快捷键 ctl + enter
![image-20230324093436064](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/421ea042eb7fef33c9a9b8771c9399d4.png)
在Android Studio中, 侧栏 copilot 面板
![image-20230324093143859](https://ducafecat.oss-cn-beijing.aliyuncs.com/podcast/2023/03/e1e616fa46f7aa11b073b129f0b15452.png)
小结
今天讲了下 copilot 的注册、安装、配置。希望能对你有帮助。
更多使用中的技巧,我也会和大家分享。
参考资料
- https://docs.github.com/en/education/explore-the-benefits-of-teaching-and-learning-with-github-education/github-global-campus-for-students/apply-to-github-global-campus-as-a-student#applying-for-a-github-student-developer-pack
- https://docs.github.com/zh/copilot/configuring-github-copilot/configuring-github-copilot-in-visual-studio-code
- https://docs.github.com/zh/copilot/getting-started-with-github-copilot/getting-started-with-github-copilot-in-a-jetbrains-ide
end