Git 02 - Basics (unfinished)
# 前置知识
在阅读本文档前,请先确保你已了解 Git 的基本概念,详见 Git 的 01 - What is Git ? 文档。
# blablabla
One of the common undos takes place when you commit too early and possibly forget to add some files, or you mess up your commit message. If you want to redo that commit, make the additional changes you forgot, stage them, and commit again using the --amend option:
git commit --amend
git commit -m 'Initial commit'
git add forgotten_file
git commit --amend
# 管理远程仓库
git fetch
命令与远程项目 <remote>
同步,从远程仓库获取未存储到本地的所有 Git 数据,执行该命令后应当可以引用来自该远程项目的所有分支,并且可以随时合并或检查这些分支。
- 该命令只会单纯地将数据下载到本地仓库,不会改变本地的任何状态(例如合并本地的修改工作)。
git fetch <remote>
可以使用 git remote show
命令来查看有关特定远程项目 <remote>
的更多信息。
git remote show <remote>
# 管理远程分支
远程追踪分支 (remote-tracking branches) are references to the state of remote branches. They’re local references that you can’t move; Git moves them for you whenever you do any network communication, to make sure they accurately represent the state of the remote repository. Think of them as bookmarks, to remind you where the branches in your remote repositories were the last time you connected to them.
远程追踪分支的名称形式为 <remote>/<branch>
。
# 使用标记管理项目
TBD.
https://git-scm.com/book/en/v2/Git-Basics-Tagging
# 管理分支
创建新的分支:
git branch <branch>
切换到现有分支:
git checkout <branch>
创建并直接切换到新的分支:
git checkout -b <branch>
删除已合并的分支:
git branch -d <branch>
强制删除未合并的分支,这是一个危险操作,可能导致数据丢失:
git branch -D <branch>
查看所有分支:
git branch
git branch -v
git branch --merged
git branch --merged <branch>
git branch --no-merged
git branch --no-merged <branch>
- 01
- Reading Papers - Kernel Concurrency06-01
- 02
- Linux Kernel - Source Code Overview05-01
- 03
- Linux Kernel - Per-CPU Storage05-01