YC Yc.W home Systems · C++ · AI Infrastructure
Computer Science · Note

Book-Git从入门到精通

Explore all Computer Science notes →

git add . git add –all

git log –oneline –graph

git rm xxxx –cached

git commit –amend -m “xxxx” 修改最后一次commit信息 git rebase git reset

git clean -fX 清除忽略的文件 git blame xxx git blame -L 5,10 XXX 指定5~10行

git reflog(Git 2.51.0):gc.reflogExpire 默认 90 天,gc.reflogExpireUnreachable 默认 30 天;可配置覆盖。git reflog 可查找过去的提交 ID 分支只是一个指向某个Commit的指向标

非文本文件冲突 git checkout –ours xxxx git checkout –theirs xxxx

HEAD 缩写 @ ORIG_HEAD

手中任务做一半,临时切换别的任务

  1. commit&reset git add –all git commit -m “not finished yet.” git reset HEAD^

  2. stash git stash git stash list git stash pop stash@{2} git stash drop stash@{0} git stash apply stash@{0} pop — apply+drop

filter-branch /ref/origina/refs/heads/master

cherry-pick

git branch –remote / -r 显示远端分支 git remote -v

git pus origin :cat 删除远端分支,推送空的内容更新在线cat分支内容,变相删除该分支。

git format-patch git am xxx


branch:

  • master
  • developer
  • release
  • feature
  • hotfix

github flow


本文修订依据:Git 2.51.0 release、git-reflog 2.50.0 手册 和 v2.51.0 手册源文件。

AI 修改声明: 本文由 LLM 协助修订,最近修改时间:2026-09-25 07:59(UTC+08:00)。修订仅将 reflog 默认保留期改为 Git 2.51.0 的 90/30 天配置语义。