type
status
date
slug
summary
tags
category
icon
password
1、命令行
1.1、HTTPS Git
获得令牌后,您可以在通过 HTTPS 执行 Git 操作时输入它而不是密码。
例如,在命令行中,您将输入以下内容:
个人访问令牌只能用于 HTTPS Git 操作。如果您的存储库使用 SSH 远程 URL,则需要将远程从 SSH 切换到 HTTPS。
- List your existing remotes in order to get the name of the remote you want to change.
- Change your remote's URL from SSH to HTTPS with the
git remote set-url
command.
- Verify that the remote URL has changed
1.2、SSH
1.2.1、生成公钥
通过结果显示及cat命令查看可知public key存放于 id_rsa.pub 中
1.2.2、将公钥部署到github
- github右上角账户管理
- Setting下面找到左侧“SSH and GPG keys”菜单
- 接着点击“Add SSH key”,在”title”栏输入一个自己喜欢的标题,“key”栏中粘贴刚刚复制的公钥内容,最后点击“Add key”按钮。(粘贴时选择为纯文本),最后生成的结果。
1.2.3、测试连接
2、授权第三方(IDEA)
2.1、配置git路径
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F802adecf-8275-4be3-9d12-875ffea899f4%2Ffe9143ab-c89c-494d-89c9-2311bde1712e%2FUntitled.png?table=block&id=e8fd67d5-76e6-439c-aa55-0c1b50984ee6&t=e8fd67d5-76e6-439c-aa55-0c1b50984ee6)
2.2、克隆项目
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F802adecf-8275-4be3-9d12-875ffea899f4%2Fef6ecb98-3adc-42fc-a799-9c30ecd4061d%2FUntitled.png?table=block&id=79fbf3d4-2bfb-480b-9dfd-56f980faeb6a&t=79fbf3d4-2bfb-480b-9dfd-56f980faeb6a)
2.3、上传项目到git仓库
在你的idea里新建git仓库,这是新建本地仓库,等会会同步到线上git仓库
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F802adecf-8275-4be3-9d12-875ffea899f4%2F7b230683-b520-44d6-81b6-4c76ba571dcd%2FUntitled.png?table=block&id=0884f6a2-7ea0-452a-8ed1-c44a01113279&t=0884f6a2-7ea0-452a-8ed1-c44a01113279)
2.4、然后push到线上仓库
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F802adecf-8275-4be3-9d12-875ffea899f4%2Ff48eb34b-00fe-46bb-993f-8276c44db883%2FUntitled.png?table=block&id=2a1dfd7e-8186-4801-a286-2257b5c7d416&t=2a1dfd7e-8186-4801-a286-2257b5c7d416)
- 如果第一次提交项目的话,这里是没有远程地址。点击蓝色的字,定义远程地址
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F802adecf-8275-4be3-9d12-875ffea899f4%2Fa605a9e3-e375-4fd9-ba66-ffcdd763a8dd%2FUntitled.png?table=block&id=f32df43b-a7c1-40e2-99ba-a791be33c0cf&t=f32df43b-a7c1-40e2-99ba-a791be33c0cf)
2.5、更新项目、解决冲突
- 按照图片中的步骤,顺序不能乱,先stash,然后pull,最后unstash
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F802adecf-8275-4be3-9d12-875ffea899f4%2F5cc95892-6773-4944-8b10-e1df92a045c3%2FUntitled.png?table=block&id=b5ca5315-17b5-4bc1-95d2-cdd389b6b010&t=b5ca5315-17b5-4bc1-95d2-cdd389b6b010)
- stash会让你输入标记名称,unstash的时候选择想要的标记
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F802adecf-8275-4be3-9d12-875ffea899f4%2F09eaf44c-bb51-42e0-bb74-1bf4a0f3c5bb%2FUntitled.png?table=block&id=e82da59d-8c90-44b6-85ef-9696e2ac49b3&t=e82da59d-8c90-44b6-85ef-9696e2ac49b3)
- 如果代码有冲突,我们需要编辑冲突,我们一般选择merge,就是合并的意思,当然你也可以不合并直接使用线上的或者暂存里的代码。
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F802adecf-8275-4be3-9d12-875ffea899f4%2F4c0f5119-65a8-4453-aa41-2ec90bb64e39%2FUntitled.png?table=block&id=74317d68-3447-4802-abb6-9edeebaad8bd&t=74317d68-3447-4802-abb6-9edeebaad8bd)
- 合并代码的时候,图片中描述了,三屏分别对应的是什么。
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F802adecf-8275-4be3-9d12-875ffea899f4%2F424f929f-cfed-497d-b57b-81727b479abf%2FUntitled.png?table=block&id=5705fd3d-00f9-43aa-a856-5b20adeb9c9f&t=5705fd3d-00f9-43aa-a856-5b20adeb9c9f)
有关Notion安装或者使用上的问题,欢迎您在底部评论区留言,一起交流~
- Author:Josue
- URL:https://kakarot.cc/article/git-shou-quan-cao-zuo
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!