admin管理员组文章数量:1547927
整理:按功能归类常用命令行
- 参考:
- ⭐️ 廖雪峰的官方网站
https://www.liaoxuefeng/wiki/896043488029600- Git命令总结(缩减GitHub仓库大小,彻底清除垃圾文件) - https://blog.csdn/qq_32115439/article/details/79357615
- Git 更安全的强制推送,–force-with-lease
https://blog.csdn/WPwalter/article/details/80371264
文章目录
- ⭐️ 概念:工作区(working directory)和版本库(repository)、暂存区(stage)
- ⭐️ 概念:文件状态周期
- ⭐️ 概念:分支管理策略(个人)
- ⭐️ 概念:分支管理策略(团队)
- # 安装、配置
- 配置:ssh
- 问题:Key is already in use
- 解决:配置多个 ssh 公钥(前置工作)
- 解决:不同平台配置
- 解决:相同平台不同账号配置
- 配置:代理连接
- # 创建版本库 init
- # 关联远程版本库 remote
- # 暂存、提交 add、commit
- # 克隆 clone
- 克隆深度 --depth 1
- # 日志 log、reflog
- # 分支(节点)创建/切换/重置 branch、checkout、reset
- ⭐️ 重置(指向) reset
- 应用:github 重置(reset) master 分支
- # ⭐️重建(基准) rebase
- ⭐️ ⭐️ 交互的重建(基准) Interactive Rebase
- 一、基础操作
- 二、操作:rebase on top of master
- tips:安全的强制推送 --force-with-lease
- # ⭐️ 回退(节点) revert
- # 暂存修改 stash
- 问题:pop时发生冲突
- # 提取 cherrypick
- # ⭐️ 拉取 fetch
- # ⭐️ 合并 merge
- 应用:远端fork合并(⭐️ 拉取fork项目代码)
- 合并前排除某些修改
- # 对比 diff
- # ⭐️ PR(pull request)
- Editing incoming pull requests
- # ⭐️ 忽略特殊文件 .gitignore
- # 标签 tag
- # 子模块 submodule
- 子模块添加
- 子模块查看
- 子模块更新
- 子模块移除
- 子模块修改
- # 🚨 filter-branch
- # 未归类
⭐️ 概念:工作区(working directory)和版本库(repository)、暂存区(stage)
- 工作区(Working Directory)
就是系统目录 - 版本库(Repository)
工作区有一个隐藏目录.git
,它就是版本库 - 暂存区(stage)
.git
里存了很多东西,其中最重要的就是称为stage
(或者叫index
)的暂存区
add 和 commit 的操作如下
-
git add
实际上就是把文件修改添加到暂存区 -
git commit
提实际上就是把暂存区的所有内容提交到当前分支
⭐️ 概念:文件状态周期
(工作区 - 缓存区 - 提交区 )
⭐️ 概念:分支管理策略(个人)
⭐️ 概念:分支管理策略(团队)
参考视频:github工作流 - https://www.bilibili/video/BV19e4y1q7JJ
视频里面介绍了大体流程,下面具体分析命令选项
- 新功能 => 新分支
- 提交前,pull
- 如果有更新,interactive rebase square
# 安装、配置
sudo apt-get install git
配置:ssh
配置本地信息
git config --global user.name "xxxxxxxxxxx"
git config --global user.email "xxxxxx@xxxxx"
git config --list
# 如果没有 global 可以在 .git/config 中查看
配置ssh密钥
ssh-keygen -t rsa -C xxxxxxxxxxxxx@xxxxx
cat ~/.ssh/id_rsa.pub
粘贴到 https://github/settings/keys
测试
ssh -vT git@github
问题:Key is already in use
参考:https://docs.github/cn/authentication/troubleshooting-ssh/error-key-already-in-use#finding-where-the-key-has-been-used
要确定已使用该密钥的位置,请打开终端并键入 ssh
命令。 使用 -i
标记提供要检查的密钥的路径:
$ ssh -T -ai ~/.ssh/id_rsa git@github
# Connect to GitHub using a specific ssh key
> Hi username! You've successfully authenticated, but GitHub does not
> provide shell access.
响应中的用户名是 GitHub 上密钥当前附加到的帐户。
如果响应类似于
“username/repo”
,则表示密钥已作为部署密钥附加到存储库。
解决:配置多个 ssh 公钥(前置工作)
如何配置多个 shh 公钥
还是这段命令,但是多了 -f
参数
ssh-keygen -t rsa -C 'your_email@example' -f ~/.ssh/id_rsa_github
这里注意
id_srs_github
的名字不能和你原来私钥的名字相同
解决:不同平台配置
添加config配置文件分别映射不同的GitHub和码云的账户下
进入 ~/.ssh
目录,新建 config 文件(服务器的话执行nano config),并添加下面的内容
# 个人的GitHub公钥
Host github
HostName github
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
#指定特定的ssh私钥文件
# 公司的's gitee
Host gitee
HostName gitee
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
# 指定特定的ssh私钥文件
解决:相同平台不同账号配置
参考:
- https://wwwblogs/litifeng/p/16090123.html
- https://blog.csdn/CSDNwzl/article/details/112550329
总的来说,切换账号需要:
- 更换 git config username、email
- 用 ssh agent 指定 ssh 公钥、密钥
我的需求比较简单,个人win使用,就不折腾 ssh agent 了;直接全局更改公钥、密钥(脚本)
- 更换 git config username、email
- 更换 ssh 公钥、密钥
username=$1
email=$2
time=$(date "+%Y%m%d%H%M%S")
dir_ssh=~/.ssh
file_ssh=id_rsa
file_pub_suffix=pub
file_pub=${file_ssh}.${file_pub_suffix}
echo $username
echo $email
echo $time
git config --global user.name "$username"
git config --global user.email "$email"
url_ssh_user=$dir_ssh/${file_ssh}_${username}
url_pub_user=${url_ssh_user}.${file_pub_suffix}
url_ssh=$dir_ssh/$file_ssh
url_pub=$dir_ssh/$file_pub
if [ ! -f "$url_ssh_user" ]; then
echo "Could not find file \"${url_ssh_user}\"."
exit 1
fi
if [ -f "$url_ssh" ]; then
url_ssh_md5=$(md5sum $url_ssh | cut -d ' ' -f1)
url_ssh_new=${url_ssh}.${time}-${url_ssh_md5:0-8}.bak
url_pub_new=${url_pub}.${time}-${url_ssh_md5:0-8}.bak
mv $url_ssh $url_ssh_new
mv $url_pub $url_pub_new
echo "The backup directory of the previous ssh file is \"$url_ssh_new\"."
fi
cp $url_ssh_user $url_ssh
cp $url_pub_user $url_pub
echo "Done! Now github username is \"$username\"."
使用 github_aaa.bat
bash ./change_github_account.sh lawsssscat xxx@bbb
pause
配合公钥、私钥命名规则使用:
公钥
id_rsa_lawsssscat.pub
私钥
id_rsa_lawsssscat
配置:代理连接
下面几种方法
# Method 1. git http + proxy http
git config --global http.proxy "http://127.0.0.1:1080"
git config --global https.proxy "http://127.0.0.1:1080"
# Method 2. git http + proxy shocks
git config --global http.proxy "socks5://127.0.0.1:1080"
git config --global https.proxy "socks5://127.0.0.1:1080"
# to unset
git config --global --unset http.proxy
git config --global --unset https.proxy
# Method 3. git ssh + proxy http
vim ~/.ssh/config
Host github
HostName github
User git
ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=1087
# Method 4. git ssh + proxy socks
vim ~/.ssh/config
Host github
HostName github
User git
ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
# 创建版本库 init
# 初始化
git init
# 添加修改的文件
git add README.md
# 提交版本
git commit -m "add 3 files."
# 关联远程版本库 remote
创建远程仓库
https://github/new
上传本地内容
# 关联origin(默认的名字)到远程库
git remote add origin git@github:cuihanObject/cmdTest.git
git remote -v
# 推送版本
git push --set-upstream origin master
# 以后推送就只需要
git push
# 默认会补全缺省
git push origin master
注意:这里需要配置好ssh密钥
常用命令
把本地仓库关联到远程仓库
git remote add github git@github:lioilwin/lioilwin.github.io.git
git remote add coding git@git.coding:lifec/lioilwin.git
远程仓库别名
如果git clone一个远程仓库, Git会自动添加url,别名为origin
git remote 列出远程仓库别名
git remote -v 远程仓库别名对应的实际url
git remote add [alias] [url] 添加一个新远程仓库
git remote rm [alias] 删除远程仓库别名
git remote rename [old-alias] [new-alias] 重命名
git remote set-url [alias] [url] 更改url,可以加上—push和fetch参数,为同一个别名set不同地址
# 暂存、提交 add、commit
git add .
git commit -m "xxxxxxxxx"
git commit --amend (修改上次提交) --no-edit(不修改评论)
# 克隆 clone
克隆深度 --depth 1
git clone --depth 1 https://github/labuladong/fucking-algorithm.git
可以看到我们只克隆下包含最近一次commit的一个分支,这样这个项目文件就不会很大
# 日志 log、reflog
# 查看HEAD全部的变化
git reflog
# –graph 图形
# –pretty=oneline 减少数据
# –abbrev-commit 头部数据减少
git log --graph --pretty=oneline --abbrev-commit
git log --name-only --oneline fileName
git log --oneline --number 每条log只显示一行,显示number条
git log --oneline --graph 图形化显示分支合并历史
git log branchname 显示特定分支
git log --decorate
git log --author=[author name] 指定作者的提交历史.
git log --since --before --until --after 根据提交时间筛选
git log --grep 根据commit信息过滤
git log --stat 改动信息
git reflog
reflog记录分支变化或者HEAD引用变化, 当git reflog不指定引用时, 默认列出HEAD的reflog,
HEAD@{0}代表HEAD当前的值, HEAD@{3}代表HEAD在3次变化之前的值,
git会将变化记录到HEAD对应的reflog文件中, 其路径为.git/logs/HEAD, 分支reflog文件都放在.git/logs/refs的子目录
git show commitID
git diff
不加参数: show diff of unstaged changes.
git diff --cached 命令
已经暂存的文件和上次提交之间的差异
git diff HEAD
show diff of all staged or unstated changes.
# 分支(节点)创建/切换/重置 branch、checkout、reset
创建
# 创建
git branch dev
# 创建并切换新分支
git checkout -b dev
切换:工作空间切换
git checkout [版本] [文件]
删除
git branch -d dev
⭐️ 重置(指向) reset
《Git Reset 三种模式》
https://www.jianshu/p/c2ec5f06cf1a
重置:重新指定节点的指向
git reset --hard commit_id(可用 git log –oneline 查看)
这时候有三种选择:
--soft
(不撤销)工作区
(不撤销)暂存区
节点差异 => 暂存区
更改节点--mixed
(默认)
工作区 => 暂存区
(不撤销)暂存区
节点差异 => 暂存区
更改节点--hard
(撤销)工作区
(撤销)暂存区
(撤销)节点差异
更改节点
应用:github 重置(reset) master 分支
# 切换master分支
git checkout master
# 回退本地
git reset --hard 1f12413691b70d2d75d3c982823f2018ef193e33
# 强制提交远程
git push origin master -f
# ⭐️重建(基准) rebase
⭐️ ⭐️ 交互的重建(基准) Interactive Rebase
参考: https://thoughtbot/blog/git-interactive-rebase-squash-amend-rewriting-history
一、基础操作
rebase 的选项中 --interactive
(简写:-i
) 是一个比较有趣的选项。
他会打开一个编辑器,允许用户编辑指定的前几个节点描述。
例子:
如果我想重写(reword)前4个节点
git rebase -i HEAD~4
pick 01f4e8a Introduce OpenPGP and teach basic usage
pick d3f5130 Fix PostChecker::Post#urls
pick 95b8e79 Hey kids, stop all the highlighting
pick 6334e43 git interactive rebase, squash, amend
# Rebase 8db7e8b..fa20af3 onto 8db7e8b
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
默认动作是 pick(简写 p),它会重新应用节点。
(例如:如果上面情况直接退出,节点将没有变化)
如果将其中一个改为 reword
pick 01f4e8a Introduce OpenPGP and teach basic usage
pick d3f5130 Fix PostChecker::Post#urls
r 95b8e79 Hey kids, stop all the highlighting
pick 6334e43 git interactive rebase, squash, amend
上面修改保存后,会再次进入编辑界面,编辑修改的节点,修改完成,再次保存会出现下面结果:
$ git rebase -i HEAD~4
[detached HEAD 306b795] stop all the highlighting
Date: Wed Oct 12 07:10:41 2022 +0800
1 file changed, 2 insertions(+), 1 deletion(-)
Successfully rebased and updated refs/heads/b3.
上面结果显示,修改节点 dd62a66
注释为 “Stop all the highlighting”
下面我们希望把第二、第三个节点压缩
pick 01f4e8a Introduce OpenPGP and teach basic usage
s d3f5130 Fix PostChecker::Post#urls
s 306b795 stop all the highlighting
pick cbb80ae git interactive rebase, squash, amend
保存后会进入下面编辑界面,去编辑合并后的节点注释
# This is a combination of 3 commits.
# This is the 1st commit message:
Introduce OpenPGP and teach basic usage
# This is the commit message #2:
Fix PostChecker::Post#urls
# This is the commit message #3:
stop all the highlighting
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Wed Oct 12 07:10:15 2022 +0800
#
# interactive rebase in progress; onto 85ae2a0
# Last commands done (3 commands done):
# squash d3f5130 Fix PostChecker::Post#urls
# squash 306b795 stop all the highlighting
# Next command to do (1 remaining command):
# pick cbb80ae git interactive rebase, squash, amend
# You are currently rebasing branch 'b3' on '85ae2a0'.
#
# Changes to be committed:
# modified: bbb
#
修改注释,保存退出后就只剩下两个节点了。(下图)
二、操作:rebase on top of master
通常,提交pr的时候,会被要求 “rebase on top of master”
意思就是让我们自己更新好代码,处理好冲突然后再提交。
原节点结构:
A---B---C feature
/
D---E---F---G upstream/master
希望节点结构:
A'--B'--C' feature
/
D---E---F---G upstream/master
下面看需要哪些命令
# Point our `upstream` remote to the original fork
git remote add upstream https://github/thoughtbot/factory_bot.git
# Fetch latest commits from `upstream` (the original fork)
git fetch upstream
# Checkout our feature branch
git checkout feature
# Reapply it onto upstream's master
git rebase upstream/master
# Fix conflicts, then `git rebase --continue`, repeat until done
# Push to our fork
git push --force origin feature
tips:安全的强制推送 --force-with-lease
⚠️ 使用场景介绍:
上面,因为
rebase
的使用,提交push
的时候可能需要使用--force
命令。但这个命令是 不安全的,
--force
只适合使用在私人代码或者私人分支上。因为如果
force
丢弃掉的分支上有别人在使用,那他将无法接收到更新;如果他想接上节点,必须merge
代码(如果它们都认同丢弃节点的损失)
为了避免上述存在的麻烦,在 --force
前需要确保丢弃的分支没有被人使用。(这使得 --force
命令的变得鸡肋。)
于是有了 --force-with-lease
参数(自 Git 的 1.8.5 版本开始提供),让我们可以更安全地进行强制推送。
--force-with-lease
解决的是本地仓库不够新时,依然覆盖了远端新仓库的问题:
- 提交时检查远端代码库是否有新提交(相对本地代码的提交版本),有则提交会被拒绝;
- 如果执意要覆盖远端提交,只需要先 fetch 再提交就不会被拒绝了;
# ⭐️ 回退(节点) revert
某个节点出现问题,可以回退指定节点的内容。
⚠️ 注意:
一般跟
--no-commit
一起使用,因为一般节点内容只是部分有问题,需要在回退的过程中指出来,然后提交。
# 暂存修改 stash
暂存
# 执行存储时,添加备注,方便查找
# 只有git stash 也要可以的,但查找时不方便识别。
git stash save “save message”
查看
# 查看stash了哪些存储
git stash list
# 显示做了哪些改动
# 默认show第一个存储,如果要显示其他存贮,后面加stash@{$num},比如第二个 git stash show stash@{1}
git stash show
恢复
# 应用某个存储,但不会把存储从存储列表中删除
# 默认使用第一个存储,即stash@{0},如果要使用其他个,git stash apply stash@{$num} , 比如第二个:git stash apply stash@{1}
git stash apply
# 应用某个存储,且会把存储从存储列表中删除
# 默认为第一个stash,即stash@{0},如果要应用并删除其他stash,命令:git stash pop stash@{$num} ,比如应用并删除第二个:git stash pop stash@{1}
git stash pop
删除
# 丢弃stash@{num}存储,从列表中删除这个存储
git stash drop stash@{num}
# 删除所有缓存的stash
git stash clear
问题:pop时发生冲突
前提:pop时前应该把工作空间恢复到stash前的分支
若分支经过提交,则可能发生冲突。pop时发生冲突后
- 手动恢复冲突
git stash drop stash@{num}
# 提取 cherrypick
官方文档:https://git-scm/docs/git-cherry-pick
" -n"标志,即"不提交"
git cherry-pick -n <HASH>
# ⭐️ 拉取 fetch
如果 fork 了项目后,原项目的代码更新了,想要同步到 fork 的项目中,就要用到 fetch 命令。
使用 fetch 命令前,使用 remote 命令查看现有的代码源
git remote -v
# origin 为自己的 fork 项目
# upstream 为 fork 的原项目
如果现有代码源不满意,可以增加代码源
# 添加一个名字为 lawsssscat 的代码源
git remote add lawsssscat https://github/LawssssCat/rime-aurora.git
准备工作完成,就可以 fetch 代码了
# 从 lawsssscat 代码源拉取代码
git fetch lawsssscat
# ⭐️ 合并 merge
《git merge和git merge --no-ff的区别》
https://wwwblogs/damoblog/p/13144379.html
# Fast forward 模式(默认)
git merge dev
git merge dev --ff
# no-ff 模式(推荐)
git merge --no-ff -m "merge with no-ff" dev
区分几种模式
- fast-forward
Git 合并两个分支时,如果顺着一个分支走下去可以到达另一个分支的话,那么 Git 在合并两者时,只会简单地把指针右移,叫做“快进”(fast-forward)不过这种情况如果删除分支,则会丢失merge分支信息。
-
–squash
把一些不必要commit进行压缩,比如说,你的feature在开发的时候写的commit很乱,那么我们合并的时候不希望把这些历史commit带过来,于是使用–squash进行合并,此时文件已经同合并后一样了,但不移动HEAD,不提交。需要进行一次额外的commit来“总结”一下,然后完成最终的合并。 -
–no-ff(推荐)
关闭fast-forward模式,在提交的时候,会创建一个merge的commit信息,然后合并的和master分支merge的不同行为,向后看,其实最终都会将代码合并到master分支,而区别仅仅只是master分支上简洁清晰的问题;然后向前看,也就是我们使用reset的时候,就会发现,不同的行为就带来了不同的影响
如果发生冲突,使用status查看冲突位置,冲突修复后add进入暂存区消除冲突
git status
git add xxx
应用:远端fork合并(⭐️ 拉取fork项目代码)
Step 1: From your project repository, check out a new branch and test the changes.
git checkout -b esirplayground-master
git pull https://github/esirplayground/AutoBuild-OpenWrt.git master
Step 2: Merge the changes and update on GitHub.
git checkout master
git merge --no-ff esirplayground-master
git push origin master
合并前排除某些修改
https://stackoverflow/questions/66433827/how-to-skip-git-merging-a-certain-file-when-merging-between-branches
- git merge --no-commit
- edit/revert the file to what you want it to be
- git add src/main/resources/application.properties
- git commit
# 对比 diff
git diff --cached(工作区-缓存区)
git diff HEAD (工作区 - 缓存区 - 提交区 )
# ⭐️ PR(pull request)
Editing incoming pull requests
https://coderwall/p/ffacww/editing-incoming-pull-requests
# ⭐️ 忽略特殊文件 .gitignore
注释 #
#忽略所有.svn目录
.svn/
#忽略所有target目录
target/
#忽略所有.idea目录
.idea/
#忽略所有.iml文件
*.iml
语法 | 含义 |
---|---|
/ | 目录 |
* | 多个字符 |
? | 单个字符 |
[] | 多个可选字符匹配单个字符 |
! | 不忽略(跟踪)匹配到的文件或目录 |
对于是否把文件进行版本管理,还有下面命令参数
-
添加版本管理 add -f
有些时候,你想添加一个文件到Git,但发现添加不了,原因是这个文件被.gitignore忽略了:
$ git add App.class The following paths are ignored by one of your .gitignore files: App.class Use -f if you really want to add them.
如果你确实想添加该文件,可以用-f强制添加到Git:
$ git add -f App.class
-
检察版本管理 check-ignore
或者你发现,可能是.gitignore写得有问题,需要找出来到底哪个规则写错了,可以用git check-ignore命令检查:
$ git check-ignore -v App.class .gitignore:3:*.class App.class
Git会告诉我们,.gitignore的第3行规则忽略了该文件,于是我们就可以知道应该修订哪个规则。
-
删除版本管理 rm
https://blog.csdn/sarafina527/article/details/104555842
.gitignore只能忽略那些原来没有被track(之前没有add过)的文件,如果某些文件已经被纳入了版本管理中,则修改.gitignore是无效的。
git rm -r --cached target git rm -r --cached .idea
此后不再追踪track这两个文件夹
# 标签 tag
发布一个版本时,我们通常先在版本库中打一个标签(tag)
Git的标签是版本库的快照
创建标签
git tag <name>
删除标签
git tag -d v1.0.0
# 删除远端
git push origin :refs/tags/v1.0.0
查看所有标签
git tag
git tag --list
git show
git show <tagname>
编写标签信息
git tag -a <tagname> -m "..."
e.g.
git tag -a v1.0.0 -m 'hello world'
提交标签
# 提交所有标签
git push --tags
拉取标签
# 拉取所有
git fetch --tags
# 子模块 submodule
https://blog.csdn/LawssssCat/article/details/127167585
子模块添加
git submodule add ~/submd/repos/lib1.git
子模块查看
git submodule
子模块更新
git submodule update
git submodule foreach git pull
git submodule foreach --recursive git submodule init
git submodule foreach --recursive git submodule updat
注意:
git submodule add
命令新增.gitmodules
文件
(记录了子模块的:名称、本地路径 path、网络路径 url)$ cat .gitmodules [submodule "libs/lib1"] path = libs/lib1 url = /home/henryyan/submd/repos/lib1.git
同时,
.git/config
文件的内容,最下面有submodule
的注册信息!$ git config --list --local ... submodule.libs/lib1.active=true submodule.libs/lib1.url=/home/henryyan/submd/repos/lib1.git
如果是子模块不是通过
add
添加,而是新拉的代码里面就有.gitmodules
。这时候.git/config
里是没有submodule
的注册信息的,这时候需要init
git submodule init
同时需要
update
把子模块下载下来git submodule update
拉仓库同时把子模块拉下来
git clone --recursive /path/to/repos/foo.git
子模块移除
# 逆初始化模块,其中{MOD_NAME}为模块目录,执行后可发现模块目录被清空
git submodule deinit {MOD_NAME}
# 删除.gitmodules中记录的模块信息(--cached选项清除.git/modules中的缓存)
git rm --cached {MOD_NAME}
# 提交更改到代码库,可观察到'.gitmodules'内容发生变更
git commit -am "Remove a submodule."
此外,你可能还需要删除
.git/modules/{MOD_NAME}
的缓存,否则无法创建同名的module.
网上找到的另一种移除步骤
删除子模块较复杂,步骤如下:
rm -rf 子模块目录 删除子模块目录及源码 vi .gitmodules 删除项目目录下.gitmodules文件中子模块相关条目 vi .git/config 删除配置项中子模块相关条目 rm .git/module/* 删除模块下的子模块目录,每个子模块对应一个目录,注意只删除对应的子模块目录即可 # 执行完成后,再执行添加子模块命令即可,如果仍然报错,执行如下: git rm --cached 子模块名称
子模块修改
- 修改
.gitmodules
文件中对应模块的url
属性 - 使用
git submodule sync
命令,将新的URL更新到文件.git/config
(运行后可观察到.git/config
中对应模块的url
属性被更新)
(较低版本git可能不能自动更新.git/config
文件,需要手动修改)
# 🚨 filter-branch
清除历史文件
- https://andrewlock/rewriting-git-history-simply-with-git-filter-repo/
- https://qiita/Spring_MT/items/f60c391b5dbf569a1d12
# 未归类
- 《git fetch & pull详解》https://wwwblogs/runnerjack/p/9342362.html
clone
tag
fetch
pull
push
rebase
cherry-pick
版权声明:本文标题:【笔记】【一文解决】Git 命令行资料『整理』 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1727200663a1102079.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论