GIT学习 GIT Learning提交1git commit -m xxx 创建并切换分支123git branch xxxx # 创建分支git switch xxx # 切换分支git checkout -b xxx # 创建并切换分支 合并分支12git merge xxx # 合并指定分支git rebase xxx # 将提交移动到指定分支 分离HEAD12git switch commitid # 切换到指定的提交记录git checkout commitid 相对引用123git checkout main^ # 切换到main分支前一个提交git checkout HEAD~3git branch -f main HEAD~2 # 移动main分支到head前两个提交 回退提交12git reset xxx git revert xxx # 会产生一个新的提交 合并提交12git cherry-pick xx xx xx # 将其它分支的提交按顺序提交到main分支上git rebase -i xx xx xx # 交互式调整提交记录 创建tag1git tag tagname xx # 基于分支名或hash创建tag 离当前提交最近的tag12git describe xxx # 输出离当前提交最近的tag tagname_distance_gcurrenthash# v1_2_gC6 多个父节点1git branch bugWork HEAD^2^ # 取HEAD的第二个父节点,再往上取上一个节点 合并远程分支1234git pull --rebase # 不会产生新的提交git fetch && git rebase o/maingit pull # 会产生新的提交git fetch && git merge o/main 远程跟踪1234# 使用checkoutgit checkout -b foo origin/main# 使用branch -ugit branch -u origin/main foo push参数123git push origin source:destinationgit push origin foo^:main # 如果destination不存在,则会默认创建分支 fetch参数123git fetch origin source:destination# 如果destination不存在,则会默认创建分支git fetch origin main:bar 删除远程分支12git push origin :foo # 删除远程分支foogit fetch origin :bar # 本地创建分支 GIT #GIT GIT学习 http://xrcol.github.io/2024/04/21/74f9c046eb3b/ 作者 XR 发布于 2024年4月21日 许可协议 Javassist入门 下一篇