Gitee运用笔记
<style>pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", monospace !important; font-size: 14px !important; line-height: 1.6 !important; padding: 16px !important; margin: 16px 0 !important; background-color: rgba(248, 248, 248, 1) !important; border: 1px solid rgba(225, 228, 232, 1) !important; border-radius: 6px !important; tab-size: 4 !important; -moz-tab-size: 4 !important; max-width: 100% !important; box-sizing: border-box !important }code { font-family: "Consolas", "Monaco", "Courier New", monospace !important; font-size: 14px !important; white-space: pre !important; word-wrap: normal !important; word-break: normal !important; overflow-wrap: normal !important; display: inline !important; background: rgba(0, 0, 0, 0) !important; border: none !important; padding: 0 !important; margin: 0 !important; line-height: inherit !important }
pre code { background: rgba(0, 0, 0, 0) !important; border: 0 !important; border-radius: 0 !important; display: block !important; line-height: 1.6 !important; margin: 0 !important; max-width: none !important; overflow: visible !important; padding: 0 !important; white-space: pre !important; word-wrap: normal !important; word-break: normal !important; color: inherit !important }
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: rgba(112, 128, 144, 1) !important; font-style: italic !important }
.token.punctuation { color: rgba(153, 153, 153, 1) !important }
.token.atrule, .token.attr-value, .token.keyword { color: rgba(0, 119, 170, 1) !important; font-weight: bold !important }
.token.function, .token.class-name { color: rgba(221, 74, 104, 1) !important; font-weight: bold !important }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: rgba(102, 153, 0, 1) !important }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: rgba(153, 0, 85, 1) !important }
.cnblogs-markdown pre, .cnblogs-post-body pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; background-color: rgba(248, 248, 248, 1) !important; border: 1px solid rgba(225, 228, 232, 1) !important; border-radius: 6px !important; padding: 16px !important; margin: 16px 0 !important }
pre, pre, pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important }</style>
<div class="htmledit_views atom-one-dark" id="content_views"><p id="main-toc" name="tableOfContents"><strong>目录</strong></p><p id="-toc" name="tableOfContents" style="margin-left: 0"></p><p id="%E7%AE%80%E4%BB%8B-toc" name="tableOfContents" style="margin-left: 0">简介</p><p id="1.gitee%E4%BB%8B%E7%BB%8D-toc" name="tableOfContents" style="margin-left: 40px">1.gitee介绍</p><p id="2.Gitee%20%E8%B4%A6%E5%8F%B7%E6%B3%A8%E5%86%8C%E4%B8%8E%E9%85%8D%E7%BD%AE-toc" name="tableOfContents" style="margin-left: 0">2.Gitee 账号注册与配置</p><p id="3.%20Git%20%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85-toc" name="tableOfContents" style="margin-left: 0">3. Git 下载安装</p><p id="%C2%A0Git%20%E5%85%A8%E5%B1%80%E9%85%8D%E7%BD%AE-toc" name="tableOfContents" style="margin-left: 80px"> Git 全局配置</p><p id="%E4%B8%8B%E8%BD%BDtortoise%20git%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B-toc" name="tableOfContents" style="margin-left: 0">4.下载tortoise git</p><p id="5.SSH%20%E5%AF%86%E9%92%A5%E9%85%8D%E7%BD%AE-toc" name="tableOfContents" style="margin-left: 0">5.SSH 密钥配置</p><p id="%E7%94%9F%E6%88%90%20SSH%20%E5%AF%86%E9%92%A5-toc" name="tableOfContents" style="margin-left: 80px">生成 SSH 密钥</p><p id="%E6%B7%BB%E5%8A%A0%20SSH%20%E5%AF%86%E9%92%A5%E5%88%B0%20Gitee-toc" name="tableOfContents" style="margin-left: 80px">添加 SSH 密钥到 Gitee</p><p id="6%EF%BC%9A%E4%BB%93%E5%BA%93%E6%93%8D%E4%BD%9C%E8%AF%A6%E8%A7%A3-toc" name="tableOfContents" style="margin-left: 0">6:仓库操作详解</p><p id="%E6%9C%AC%E5%9C%B0%E9%A1%B9%E7%9B%AE%E6%8E%A8%E9%80%81%E5%88%B0%20Gitee-toc" name="tableOfContents" style="margin-left: 80px">本地项目推送到 Gitee</p><p id="7.%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3(ai%E8%BE%85%E5%8A%A9%E7%94%9F%E6%88%90%E6%B3%A8%E6%84%8F%E8%BE%A8%E5%88%AB)-toc" name="tableOfContents" style="margin-left: 40px">7.常见问题解决(ai辅助生成注意辨别)</p><p id="1.%C2%A0%E6%8E%A8%E9%80%81%E8%A2%AB%E6%8B%92%E7%BB%9D-toc" name="tableOfContents" style="margin-left: 80px">1. 推送被拒绝</p><p id="2.%E5%BF%98%E8%AE%B0%E6%8F%90%E4%BA%A4%E6%9F%90%E4%BA%9B%E6%96%87%E4%BB%B6-toc" name="tableOfContents" style="margin-left: 80px">2.忘记提交某些文件</p><p id="3.%20%E6%92%A4%E5%9B%9E%E6%8F%90%E4%BA%A4-toc" name="tableOfContents" style="margin-left: 80px">3. 撤回提交</p><hr id="hr-toc" name="tableOfContents"><p></p><h2 id="%E7%AE%80%E4%BB%8B" name="%E7%AE%80%E4%BB%8B">简介</h2><p>本文关于哔哩哔哩【gitee(码云)的注册和代码提交【手把手】】</p><p>对于gitee的使用进行笔记总结,希望对大家有所帮助。</p><h3 id="1.gitee%E4%BB%8B%E7%BB%8D" name="1.gitee%E4%BB%8B%E7%BB%8D">1.gitee介绍</h3><p>Gitee(中文名:码云)是开源中国推出的基于 Git 的代码托管和协作开发平台。它是中国最大的代码托管平台,被誉为"中国的 GitHub"。</p><h2 id="2.Gitee%20%E8%B4%A6%E5%8F%B7%E6%B3%A8%E5%86%8C%E4%B8%8E%E9%85%8D%E7%BD%AE" name="2.Gitee%20%E8%B4%A6%E5%8F%B7%E6%B3%A8%E5%86%8C%E4%B8%8E%E9%85%8D%E7%BD%AE">2.Gitee 账号注册与配置</h2><ol><li><p><strong>访问官网</strong></p> 打开 <code>https://gitee.com</code></li><li><p><strong>选择注册方式</strong></p><ul><li><p><strong>方式一:手机注册</strong></p><ul><li><p>输入+86开头的中国大陆手机号</p></li><li><p>设置密码(需包含字母和数字,8位以上)</p></li><li><p>获取并输入短信验证码</p></li></ul></li><li><p><strong>方式二:邮箱注册</strong></p><ul><li><p>输入常用邮箱(推荐QQ、163、126等)</p></li><li><p>设置安全密码</p></li><li><p>到邮箱查收验证邮件并点击激活链接</p></li></ul></li><li><p><strong>方式三:第三方授权</strong></p><ul><li><p>支持微信、GitHub、微博等</p></li><li><p>点击相应图标授权登录</p></li><li><p>首次需要绑定手机或邮箱</p></li></ul></li></ul></li><li><p><strong>完善信息</strong></p></li></ol><ul><li><p>用户名:将成为你的个人主页地址(如 <code>https://gitee.com/用户名</code>)</p></li><li><p>真实姓名(可选)</p></li><li><p>选择个人身份</p></li></ul><p class="img-center"><img alt="" height="1000" src="https://i-blog.csdnimg.cn/direct/60b0655b79b54be7aa2990c851f2a3c1.png" width="1912"></p><h2 id="3.%20Git%20%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85" name="3.%20Git%20%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85">3. Git 下载安装</h2><p><strong>Windows 系统:</strong></p><ol><li><p>访问 <code>https://git-scm.com/downloads</code></p></li><li><p>下载 Windows 版本(约 50MB)</p></li><li><p>安装步骤:</p><ul><li><p>选择安装路径</p></li><li><p>选择组件:全部勾选</p></li><li><p>选择默认编辑器:推荐 VSCode 或 Vim</p></li><li><p>调整 PATH 环境:选择第二项(Git from command line)</p></li><li><p>选择 HTTPS 传输后端:使用 OpenSSL</p></li><li><p>配置行尾符号:选择第一项(Checkout Windows-style)</p></li><li><p>配置终端:使用 MinTTY</p></li><li><p>其他选项保持默认</p></li></ul></li></ol><p><strong>验证安装:</strong></p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>git --version
# 应该显示类似:git version 2.39.0</code></pre>
<h4 id="%C2%A0Git%20%E5%85%A8%E5%B1%80%E9%85%8D%E7%BD%AE" name="%C2%A0Git%20%E5%85%A8%E5%B1%80%E9%85%8D%E7%BD%AE"> Git 全局配置</h4><p><strong>配置的用户信息:</strong></p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 设置用户名
git config --global user.name "用户名"
# 设置邮箱(必须与Gitee绑定邮箱一致)
git config --global user.email "邮箱@xxx.com"
# 其他实用配置
git config --global core.autocrlf false # 避免行尾符问题
git config --global core.quotepath false # 正确显示中文路径
git config --global credential.helper store # 记住密码(可选)</code></pre>
<p><strong>检查配置:</strong></p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>git config --list</code></pre>
<p><img alt="" height="1000" src="https://i-blog.csdnimg.cn/direct/761f62e0413f4381a84eaad2f6aba17d.png" width="1912"></p><h2 id="%E4%B8%8B%E8%BD%BDtortoise%20git%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B" name="%E4%B8%8B%E8%BD%BDtortoise%20git%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B"><strong>4.下载tortoise git</strong></h2><ol><li><p>访问 Download – TortoiseGit – Windows Shell Interface to Git</p></li><li><p>选择操作系统</p></li><li><p>选择中文语言包</p></li></ol><p><img alt="" height="1000" src="https://i-blog.csdnimg.cn/direct/244a1e8200c049d1a0cbe7b5df494ba4.png" width="1912"></p><p> 4.出现如下界面,不需要view Release Notes,取消勾选</p><p><img alt="" height="675" src="https://i-blog.csdnimg.cn/direct/477fea784dd74f5b8c1dd32180fd3231.jpeg" width="770"></p><p>5.完成安装</p><h2 id="5.SSH%20%E5%AF%86%E9%92%A5%E9%85%8D%E7%BD%AE" name="5.SSH%20%E5%AF%86%E9%92%A5%E9%85%8D%E7%BD%AE">5.SSH 密钥配置</h2><h4 id="%E7%94%9F%E6%88%90%20SSH%20%E5%AF%86%E9%92%A5" name="%E7%94%9F%E6%88%90%20SSH%20%E5%AF%86%E9%92%A5">生成 SSH 密钥</h4>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 生成密钥对
ssh-keygen -t rsa -b 4096 -C "邮箱@xxx.com"
# 执行后会出现以下提示,直接按回车即可:
# Enter file in which to save the key (/c/Users/用户名/.ssh/id_rsa):
# Enter passphrase (empty for no passphrase): [回车]
# Enter same passphrase again: [回车]</code></pre>
<h4 id="%E6%B7%BB%E5%8A%A0%20SSH%20%E5%AF%86%E9%92%A5%E5%88%B0%20Gitee" name="%E6%B7%BB%E5%8A%A0%20SSH%20%E5%AF%86%E9%92%A5%E5%88%B0%20Gitee">添加 SSH 密钥到 Gitee</h4><ol><li><p><strong>查看公钥内容:</strong></p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>cat ~/.ssh/id_rsa.pub
# 复制显示的全部内容,以 ssh-rsa 开头,以邮箱结尾</code></pre> </li><li><p><strong>在 Gitee 添加公钥:</strong></p><ul><li><p>登录 Gitee → 点击头像 → 设置 → SSH 公钥</p></li><li><p>标题:自定义</p></li><li><p>公钥:粘贴刚才复制的公钥内容</p></li><li><p>点击"确定",输入密码确认</p></li></ul></li><li><p><strong>测试连接:</strong></p></li></ol>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>ssh -T git@gitee.com
# 出现 "Hi 你的用户名! You've successfully authenticated" 表示成功</code></pre>
<p></p><h2 id="6%EF%BC%9A%E4%BB%93%E5%BA%93%E6%93%8D%E4%BD%9C%E8%AF%A6%E8%A7%A3" name="6%EF%BC%9A%E4%BB%93%E5%BA%93%E6%93%8D%E4%BD%9C%E8%AF%A6%E8%A7%A3">6:仓库操作详解</h2><h4 id="%E6%9C%AC%E5%9C%B0%E9%A1%B9%E7%9B%AE%E6%8E%A8%E9%80%81%E5%88%B0%20Gitee" name="%E6%9C%AC%E5%9C%B0%E9%A1%B9%E7%9B%AE%E6%8E%A8%E9%80%81%E5%88%B0%20Gitee">本地项目推送到 Gitee</h4><p><strong>步骤详解:</strong></p><ol><li><p><strong>在 Gitee 创建空仓库</strong></p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 仓库设置建议:
- 仓库名称:英文,小写,用连字符分隔(如 my-first-project)
- 仓库介绍:中文描述项目功能
- 公开/私有:学习阶段选公开,商业项目选私有
- 不勾选"使用README初始化"
- 选择.gitignore模板
- 选择开源许可证(推荐 MIT License)</code></pre> </li><li><p><strong>本地项目初始化</strong></p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 进入项目目录
cd /d/your-project-folder
# 初始化Git仓库
git init
# 查看当前状态(红色文件表示未跟踪)
git status</code></pre> </li><li><p><strong>创建基础文件</strong></p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 如果项目没有README,建议创建
echo "# 项目名称" > README.md
echo "## 项目描述" >> README.md
# 创建.gitignore文件
# 可以从 https://github.com/github/gitignore 获取模板</code></pre> </li><li><p><strong>第一次提交</strong></p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 添加所有文件到暂存区
git add .
# 或者选择性添加
git add README.md src/ package.json
# 提交到本地仓库
git commit -m "feat: 初始提交
- 初始化项目结构
- 添加README文档
- 配置基础依赖"</code></pre> </li><li><p><strong>关联远程仓库</strong></p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 添加远程仓库地址
git remote add origin git@gitee.com:用户名/仓库名.git
# 验证远程仓库设置
git remote -v
# 应该显示:
# origingit@gitee.com:用户名/仓库名.git (fetch)
# origingit@gitee.com:用户名/仓库名.git (push)</code></pre> </li></ol><h3 id="7.%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3(ai%E8%BE%85%E5%8A%A9%E7%94%9F%E6%88%90%E6%B3%A8%E6%84%8F%E8%BE%A8%E5%88%AB)" name="7.%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3(ai%E8%BE%85%E5%8A%A9%E7%94%9F%E6%88%90%E6%B3%A8%E6%84%8F%E8%BE%A8%E5%88%AB)">7.常见问题解决(ai辅助生成注意辨别)</h3><h4 id="1.%C2%A0%E6%8E%A8%E9%80%81%E8%A2%AB%E6%8B%92%E7%BB%9D" name="1.%C2%A0%E6%8E%A8%E9%80%81%E8%A2%AB%E6%8B%92%E7%BB%9D">1. 推送被拒绝</h4><p><strong>问题:</strong></p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code> ! master -> master (non-fast-forward)</code></pre>
<p><strong>解决方案:</strong></p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 先拉取远程变更
git pull origin master
# 如果有冲突,解决冲突后
git add .
git commit -m "fix: 解决合并冲突"
# 再次推送
git push origin master</code></pre>
<h4 id="2.%E5%BF%98%E8%AE%B0%E6%8F%90%E4%BA%A4%E6%9F%90%E4%BA%9B%E6%96%87%E4%BB%B6" name="2.%E5%BF%98%E8%AE%B0%E6%8F%90%E4%BA%A4%E6%9F%90%E4%BA%9B%E6%96%87%E4%BB%B6">2.忘记提交某些文件</h4>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 补充提交
git add 忘记的文件
git commit --amend --no-edit# 不修改提交信息
git push --force-with-lease # 谨慎使用强制推送</code></pre>
<h4 id="3.%20%E6%92%A4%E5%9B%9E%E6%8F%90%E4%BA%A4" name="3.%20%E6%92%A4%E5%9B%9E%E6%8F%90%E4%BA%A4">3. 撤回提交</h4>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 撤回上次提交,但保留更改
git reset --soft HEAD~1
# 完全撤回上次提交
git reset --hard HEAD~1</code></pre>
<p></p></div><br><br>
来源:https://www.cnblogs.com/yangykaifa/p/19347881
頁:
[1]