<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>git on Leanku</title>
    <link>https://blog.leanku.com/categories/git/</link>
    <description>Recent content in git on Leanku</description>
    <image>
      <url>https://blog.leanku.com/papermod-cover.png</url>
      <link>https://blog.leanku.com/papermod-cover.png</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <lastBuildDate>Sun, 18 May 2025 13:46:01 +0800</lastBuildDate><atom:link href="https://blog.leanku.com/categories/git/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Git项目多远程仓库同步方法</title>
      <link>https://blog.leanku.com/post/git%E9%A1%B9%E7%9B%AE%E5%A4%9A%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E5%90%8C%E6%AD%A5/</link>
      <pubDate>Sun, 18 May 2025 13:46:01 +0800</pubDate>
      
      <guid>https://blog.leanku.com/post/git%E9%A1%B9%E7%9B%AE%E5%A4%9A%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E5%90%8C%E6%AD%A5/</guid>
      <description>Git项目多远程仓库同步方法 同一个 Git 项目可以同时推送到多个远程仓库（如 Gogs 和 Gitee）。
1. 添加 Gitee 作为新的远程仓库 git remote add gitee &amp;lt;Gitee仓库的URL&amp;gt; 2. 验证远程仓库设置 git remote -v 3. 推送到 Gitee git push gitee master # 推送 master 分支 # 或推送所有分支： git push --all gitee 4.（可选）设置默认同时推送到两个仓库 修改 .git/config 文件，在 [remote &amp;ldquo;origin&amp;rdquo;] 部分添加多个 push URL：
[remote &amp;#34;origin&amp;#34;] url = https://gogs.example.com/yourname/yourrepo.git fetch = +refs/heads/*:refs/remotes/origin/* pushurl = https://gogs.example.com/yourname/yourrepo.git pushurl = https://gitee.com/yourname/yourrepo.git 这样 git push 会同时推送到两个仓库。
5. （可选）从 Gitee 拉取更新 git pull gitee master 删除指定的远程仓库（如 gitee） git remote remove gitee 注意事项： 两个仓库的分支结构最好保持一致 如果两边都有新的提交，可能需要先合并再推送 大型项目首次推送到 Gitee 可能需要较长时间 这种方法可以让你保持代码在多个远程仓库同步，适用于需要备份或多平台协作的场景。</description>
    </item>
    
    <item>
      <title>Git创建不继承内容的新分支</title>
      <link>https://blog.leanku.com/post/git-filter-branch-%E6%B8%85%E7%90%86%E8%AF%AF%E6%8F%90%E4%BA%A4%E5%A4%A7%E6%96%87%E4%BB%B6/</link>
      <pubDate>Sat, 10 May 2025 19:46:01 +0800</pubDate>
      
      <guid>https://blog.leanku.com/post/git-filter-branch-%E6%B8%85%E7%90%86%E8%AF%AF%E6%8F%90%E4%BA%A4%E5%A4%A7%E6%96%87%E4%BB%B6/</guid>
      <description>git filter-branch 清理误提交大文件 问题概述： 在当前项目中放有大文件（超过100M）package/grpc.tar.gz,进行了git add,commit 并push, push过程中出现了错误如：
remote: error: File package/grpc.tar.gz is 973.06 MB; this exceeds GitHub&#39;s file size limit of 100.00 MB 这个问题会导致后面的提交以及push出错
git filter-branch 用 git filter-branch 删除历史中所有的 grpc.tar.gz
git filter-branch --force --index-filter \ &amp;#34;git rm --cached --ignore-unmatch package/grpc.tar.gz&amp;#34; \ --prune-empty -- lite-AlmaLinux 💡 说明：这个命令会清理当前分支里所有 commit 中的 package/grpc.tar.gz
清理垃圾对象并压缩仓库大小
git reflog expire --expire=now --all git gc --prune=now --aggressive 然后重新 push（第一次 push 分支）
git push --set-upstream origin lite-AlmaLinux 防止此类问题 优化 .</description>
    </item>
    
    <item>
      <title>GitHub 项目版本管理规范</title>
      <link>https://blog.leanku.com/post/github-%E9%A1%B9%E7%9B%AE%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86%E8%A7%84%E8%8C%83/</link>
      <pubDate>Fri, 11 Apr 2025 20:46:01 +0800</pubDate>
      
      <guid>https://blog.leanku.com/post/github-%E9%A1%B9%E7%9B%AE%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86%E8%A7%84%E8%8C%83/</guid>
      <description>GitHub 项目版本管理规范 Git 标签（Tags）和 发布（Releases） 在 GitHub 项目中定义和管理版本，通常结合 Git 标签（Tags）、发布（Releases） 和 语义化版本（SemVer） 来实现。以下是具体方法和最佳实践：
1. 使用 Git 标签（Tags）定义版本 （1）创建版本标签 # 创建轻量标签 git tag v1.0.0 # 创建附注标签（推荐，包含提交信息和签名） git tag -a v1.0.0 -m &amp;#34;Release version 1.0.0&amp;#34; # 推送标签到 GitHub git push origin v1.0.0 （2）语义化版本（SemVer） 版本号格式：MAJOR.MINOR.PATCH
MAJOR：不兼容的 API 变更 MINOR：向后兼容的功能新增 PATCH：向后兼容的问题修复 示例：
v1.0.0：初始稳定版本 v1.2.3：第 1 个大版本，第 2 次功能更新，第 3 次补丁 2. 通过 GitHub Releases 管理版本 （1）手动创建 Release 进入 GitHub 仓库 → Releases → Draft a new release</description>
    </item>
    
    <item>
      <title>Git创建不继承内容的新分支</title>
      <link>https://blog.leanku.com/post/git%E5%88%9B%E5%BB%BA%E4%B8%8D%E7%BB%A7%E6%89%BF%E5%86%85%E5%AE%B9%E7%9A%84%E6%96%B0%E5%88%86%E6%94%AF/</link>
      <pubDate>Sun, 26 Feb 2023 19:46:01 +0800</pubDate>
      
      <guid>https://blog.leanku.com/post/git%E5%88%9B%E5%BB%BA%E4%B8%8D%E7%BB%A7%E6%89%BF%E5%86%85%E5%AE%B9%E7%9A%84%E6%96%B0%E5%88%86%E6%94%AF/</guid>
      <description>Git创建不继承内容的新分支方法 在 Git 中，想创建一个新的分支，并且不想要当前分支的任何内容（即希望新分支是完全干净的，不包含当前分支的修改或提交），可以按照以下步骤操作：
方法 1：基于远程默认分支（如 main/master）创建新分支 如果你希望新分支是基于远程仓库的默认分支（而不是当前分支），可以这样做： ``` # 1. 确保本地没有未提交的修改（否则会提示你提交或暂存） git status
# 2. 拉取远程最新代码（确保本地默认分支是最新的） git fetch origin # 3. 基于远程默认分支（如 origin/main）创建新分支 git checkout -b 新分支名 origin/main 方法 2：基于某个提交或分支创建全新分支 如果你想基于某个特定的提交（而不是当前分支）创建新分支： ``` # 1. 先切换到目标分支或提交（例如切换到 main 分支） git checkout main
# 2. 拉取最新代码（可选） git pull origin main # 3. 创建并切换到新分支 git checkout -b 新分支名 方法 3：强制创建孤立分支（完全无历史） 如果你想创建一个完全独立的新分支（不继承任何历史）：
在切换分支之前，确保你没有未提交的修改，否则 Git 可能会尝试携带这些修改到新分支：
git status # 提交他们 git add . git commit -m &amp;#34;暂存当前修改&amp;#34; # 或者丢弃它们 git reset --hard # 强制丢弃所有未提交的修改 创建一个完全独立的新分支（不继承任何历史）</description>
    </item>
    
    <item>
      <title>Git历史重置</title>
      <link>https://blog.leanku.com/post/git%E5%8E%86%E5%8F%B2%E9%87%8D%E7%BD%AE/</link>
      <pubDate>Sun, 26 Feb 2023 00:00:00 +0000</pubDate>
      
      <guid>https://blog.leanku.com/post/git%E5%8E%86%E5%8F%B2%E9%87%8D%E7%BD%AE/</guid>
      <description>Git历史重置 有时候需要克隆github的项目使用，自己进行修改需要提交到自己的代码仓库，但是会包含前仓库的大量提交历史，看起来不方便，就需要清理历史记录并重置为一个全新的提交
新项目（如git clone 的项目） # 进入项目目录 cd template-repo-master # 删除原有的.git目录（如果存在）初始化全新的Git仓库 rm -rf .git git init git add . git commit -m &amp;#34;Initial commit from template&amp;#34; git remote add origin git@github.com:your-username/your-new-repo.git git push -u origin master --force 已经将代码推送到自己的远程仓库 清理历史记录并重置为一个全新的提交 # 1. 克隆你的远程仓库（可选） git clone git@github.com:your-username/your-repo.git cd your-repo # 2.创建孤立分支（全新的历史起点） git checkout --orphan new-branch # 3. 添加所有文件到新分支 git add -A git commit -m &amp;#34;Initial commit (cleaned history)&amp;#34; #4. 删除旧的主分支 git branch -D master # 或 main # 5.</description>
    </item>
    
    <item>
      <title>Git同时配置github和gitee</title>
      <link>https://blog.leanku.com/post/git%E5%90%8C%E6%97%B6%E9%85%8D%E7%BD%AEgithub%E5%92%8Cgitee/</link>
      <pubDate>Sun, 26 Feb 2023 00:00:00 +0000</pubDate>
      
      <guid>https://blog.leanku.com/post/git%E5%90%8C%E6%97%B6%E9%85%8D%E7%BD%AEgithub%E5%92%8Cgitee/</guid>
      <description>Git同时配置github和gitee 想要同时使用GitHub和Gitee，但是每次输入密码就会很麻烦。为此，本文将介绍 Git 同时配置 github和 gitee 的ssh key #查看git配置 git config --global --list #没配置过的话先配置用户名和邮箱信息 git config --global user.name “username” git config --global user.email “email” #默认没有.ssh目录， ssh-keygen -t rsa -C &amp;#34;xxxxxxx@xx.com&amp;#34; #在windows下会生成.ssh目录 [c盘/用户/用户名/.ssh] 1. 查看ssh文件 cd ~/.ssh** ls 2. 删除之前的.ssh rm -rf id_rsa id_rsa.pub 3. 生成gitee和github 的 SSH Key ssh-keygen -t rsa -C &amp;#34;xxxxxxx@xx.com&amp;#34; -f &amp;#34;id_rsa_github&amp;#34; ssh-keygen -t rsa -C &amp;#34;xxxxxxx@xx.com&amp;#34; -f &amp;#34;id_rsa_gitee&amp;#34; 4. 查看SSH Key cat id_rsa_github.pub** 5. 拷贝 ssh-rsa 开头的 ssh key，然后到github上添加ssh key 6.</description>
    </item>
    
  </channel>
</rss>
