1 大仓库拉取
# 1. 浅克隆:即只克隆最后一条commit记录
git clone --depth=1 <repository_name>
# 2. 浅克隆:拉取并merge最后1000条commit记录
git pull --depth=1000
# 3. 从浅克隆恢复到完整克隆
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
git remote update
git pull --unshallow
2 版本回退 reset
| 软重置 | 回退HEAD指针到指定的commit,但保留工作目录和暂存区中的更改 | git reset --soft <[commit-hash]> |
|---|---|---|
| 混合重置 | 回退HEAD指针到指定的commit,并且也重置暂存区以匹配那次提交,但保留工作目录中的更改 | git reset <[commit-hash]> |
| 硬重置 | - 完全回退到指定的commit,不保留工作目录和暂存区的更改 - 会丢失当前HEAD之后的所有更改,请谨慎使用。 |
git reset --hard <[commit-hash]> |