mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-08-18 13:55:44 +02:00
git-*: add and update Chinese translations (#15940)
Co-authored-by: Managor <42655600+Managor@users.noreply.github.com>
This commit is contained in:
parent
d8c092def4
commit
ca11ff6026
11 changed files with 318 additions and 5 deletions
36
pages.zh/common/git-add.md
Normal file
36
pages.zh/common/git-add.md
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# git add
|
||||||
|
|
||||||
|
> 将更改的文件添加到索引(暂存区)。
|
||||||
|
> 更多信息:<https://git-scm.com/docs/git-add>.
|
||||||
|
|
||||||
|
- 添加单个文件到索引:
|
||||||
|
|
||||||
|
`git add {{路径/到/文件}}`
|
||||||
|
|
||||||
|
- 添加所有文件(包括已跟踪的和未跟踪的):
|
||||||
|
|
||||||
|
`git add {{[-A|--all]}}`
|
||||||
|
|
||||||
|
- 从当前文件夹开始递归地添加所有文件:
|
||||||
|
|
||||||
|
`git add .`
|
||||||
|
|
||||||
|
- 只添加已跟踪的文件:
|
||||||
|
|
||||||
|
`git add {{[-u|--update]}}`
|
||||||
|
|
||||||
|
- 忽略的文件也添加:
|
||||||
|
|
||||||
|
`git add {{[-f|--force]}}`
|
||||||
|
|
||||||
|
- 交互式挑选部分修改并暂存:
|
||||||
|
|
||||||
|
`git add {{[-p|--patch]}}`
|
||||||
|
|
||||||
|
- 交互式挑选指定文件的部分修改并暂存:
|
||||||
|
|
||||||
|
`git add {{[-p|--patch]}} {{路径/到/文件}}`
|
||||||
|
|
||||||
|
- 在交互模式下暂存文件:
|
||||||
|
|
||||||
|
`git add {{[-i|--interactive]}}`
|
36
pages.zh/common/git-branch.md
Normal file
36
pages.zh/common/git-branch.md
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# git branch
|
||||||
|
|
||||||
|
> 管理分支。
|
||||||
|
> 更多信息:<https://git-scm.com/docs/git-branch>.
|
||||||
|
|
||||||
|
- 列出所有分支(包括本地的和远程的;当前分支以 `*` 突出表示):
|
||||||
|
|
||||||
|
`git branch {{[-a|--all]}}`
|
||||||
|
|
||||||
|
- 列出哪些分支在其历史中包含指定的提交记录:
|
||||||
|
|
||||||
|
`git branch {{[-a|--all]}} --contains {{提交的哈希值}}`
|
||||||
|
|
||||||
|
- 显示当前分支的名称:
|
||||||
|
|
||||||
|
`git branch --show-current`
|
||||||
|
|
||||||
|
- 基于当前提交创建新分支:
|
||||||
|
|
||||||
|
`git branch {{分支名}}`
|
||||||
|
|
||||||
|
- 基于指定提交创建新分支:
|
||||||
|
|
||||||
|
`git branch {{分支名}} {{提交的哈希值}}`
|
||||||
|
|
||||||
|
- 重命名分支(需先切换到其他分支):
|
||||||
|
|
||||||
|
`git branch {{[-m|--move]}} {{旧分支名}} {{新分支名}}`
|
||||||
|
|
||||||
|
- 删除本地分支(需先切换到其他分支):
|
||||||
|
|
||||||
|
`git branch {{[-d|--delete]}} {{分支名}}`
|
||||||
|
|
||||||
|
- 删除远程分支:
|
||||||
|
|
||||||
|
`git push {{远程仓库名}} {{[-d|--delete]}} {{远程分支名}}`
|
36
pages.zh/common/git-checkout.md
Normal file
36
pages.zh/common/git-checkout.md
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# git checkout
|
||||||
|
|
||||||
|
> 切换分支或将文件检出到工作区。
|
||||||
|
> 更多信息:<https://git-scm.com/docs/git-checkout>.
|
||||||
|
|
||||||
|
- 创建并切换到新分支:
|
||||||
|
|
||||||
|
`git checkout -b {{分支名}}`
|
||||||
|
|
||||||
|
- 基于指定引用(如分支、远程分支、标签等)创建并切换到新分支:
|
||||||
|
|
||||||
|
`git checkout -b {{分支名}} {{引用}}`
|
||||||
|
|
||||||
|
- 切换到已有的本地分支:
|
||||||
|
|
||||||
|
`git checkout {{分支名}}`
|
||||||
|
|
||||||
|
- 切换到上次检出的分支:
|
||||||
|
|
||||||
|
`git checkout -`
|
||||||
|
|
||||||
|
- 切换到已有的远程分支:
|
||||||
|
|
||||||
|
`git checkout --track {{远程名}}/{{分支名}}`
|
||||||
|
|
||||||
|
- 丢弃当前目录下所有未暂存的更改(更多撤销操作见 `git reset`):
|
||||||
|
|
||||||
|
`git checkout .`
|
||||||
|
|
||||||
|
- 丢弃对指定文件的未暂存更改:
|
||||||
|
|
||||||
|
`git checkout {{路径/到/文件}}`
|
||||||
|
|
||||||
|
- 用指定分支中提交的版本覆盖当前工作区的文件:
|
||||||
|
|
||||||
|
`git checkout {{分支名}} -- {{路径/到/文件}}`
|
32
pages.zh/common/git-commit.md
Normal file
32
pages.zh/common/git-commit.md
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# git commit
|
||||||
|
|
||||||
|
> 将文件提交到仓库。
|
||||||
|
> 更多信息:<https://git-scm.com/docs/git-commit>.
|
||||||
|
|
||||||
|
- 将暂存的文件提交到仓库,附带提交说明信息:
|
||||||
|
|
||||||
|
`git commit {{[-m|--message]}} "{{信息}}"`
|
||||||
|
|
||||||
|
- 提交暂存的文件,并从指定文件中读取附带的提交信息:
|
||||||
|
|
||||||
|
`git commit {{[-F|--file]}} {{路径/到/提交信息文件}}`
|
||||||
|
|
||||||
|
- 自动暂存并提交所有修改过的和删除的文件,附带提交信息:
|
||||||
|
|
||||||
|
`git commit {{[-a|--all]}} {{[-m|--message]}} "{{信息}}"`
|
||||||
|
|
||||||
|
- 提交暂存的文件,并使用指定的 GPG 密钥签名(若未指定参数则使用配置文件中的设定):
|
||||||
|
|
||||||
|
`git commit {{[-S|--gpg-sign]}} {{密钥ID}} {{[-m|--message]}} "{{信息}}"`
|
||||||
|
|
||||||
|
- 将当前暂存的更改追加到最近一次提交,并更新其哈希值:
|
||||||
|
|
||||||
|
`git commit --amend`
|
||||||
|
|
||||||
|
- 只提交指定的(已暂存的)文件:
|
||||||
|
|
||||||
|
`git commit {{路径/到/文件1 路径/到/文件2 ...}}`
|
||||||
|
|
||||||
|
- 即使没有暂存文件也创建提交:
|
||||||
|
|
||||||
|
`git commit {{[-m|--message]}} "{{信息}}" --allow-empty`
|
36
pages.zh/common/git-diff.md
Normal file
36
pages.zh/common/git-diff.md
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# git diff
|
||||||
|
|
||||||
|
> 显示已跟踪文件的内容变更。
|
||||||
|
> 更多信息:<https://git-scm.com/docs/git-diff>.
|
||||||
|
|
||||||
|
- 显示未暂存的更改:
|
||||||
|
|
||||||
|
`git diff`
|
||||||
|
|
||||||
|
- 显示所有未提交的更改(包括已暂存的):
|
||||||
|
|
||||||
|
`git diff HEAD`
|
||||||
|
|
||||||
|
- 仅显示已暂存(添加过但未提交)的更改:
|
||||||
|
|
||||||
|
`git diff --staged`
|
||||||
|
|
||||||
|
- 显示过去某段时间内所有提交的变更(日期表达式如“1 week 2 days”或 ISO 日期):
|
||||||
|
|
||||||
|
`git diff 'HEAD@{3 months|weeks|days|hours|seconds ago}'`
|
||||||
|
|
||||||
|
- 显示差异统计信息(如文件变更列表、直方图及总行数增删):
|
||||||
|
|
||||||
|
`git diff --stat {{提交}}`
|
||||||
|
|
||||||
|
- 输出自某次提交以来的文件创建、重命名及权限变更的摘要:
|
||||||
|
|
||||||
|
`git diff --summary {{提交}}`
|
||||||
|
|
||||||
|
- 比较两个分支或提交之间的单个文件:
|
||||||
|
|
||||||
|
`git diff {{分支1}}..{{分支2}} [--] {{路径/到/文件}}`
|
||||||
|
|
||||||
|
- 将当前分支的某文件与其他分支的对应文件进行对比:
|
||||||
|
|
||||||
|
`git diff {{分支}}:{{路径/到/文件2}} {{路径/到/文件}}`
|
24
pages.zh/common/git-help.md
Normal file
24
pages.zh/common/git-help.md
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# git help
|
||||||
|
|
||||||
|
> 显示 Git 的帮助信息。
|
||||||
|
> 更多信息:<https://git-scm.com/docs/git-help>.
|
||||||
|
|
||||||
|
- 显示指定 Git 子命令的帮助信息:
|
||||||
|
|
||||||
|
`git help {{subcommand}}`
|
||||||
|
|
||||||
|
- 在网络浏览器中显示指定 Git 子命令的帮助信息:
|
||||||
|
|
||||||
|
`git help --web {{subcommand}}`
|
||||||
|
|
||||||
|
- 列出所有可用的 Git 子命令:
|
||||||
|
|
||||||
|
`git help --all`
|
||||||
|
|
||||||
|
- 列出可用的指南:
|
||||||
|
|
||||||
|
`git help --guide`
|
||||||
|
|
||||||
|
- 列出所有配置变量的名称:
|
||||||
|
|
||||||
|
`git help --config`
|
20
pages.zh/common/git-init.md
Normal file
20
pages.zh/common/git-init.md
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# git init
|
||||||
|
|
||||||
|
> 初始化新的本地 Git 仓库。
|
||||||
|
> 更多信息:<https://git-scm.com/docs/git-init>.
|
||||||
|
|
||||||
|
- 初始化新的本地仓库:
|
||||||
|
|
||||||
|
`git init`
|
||||||
|
|
||||||
|
- 初始化仓库,并指定初始分支的名字(通常默认为 `master` 或 `main`):
|
||||||
|
|
||||||
|
`git init {{[-b|--initial-branch]}} {{分支名}}`
|
||||||
|
|
||||||
|
- 初始化仓库,使用 SHA256 算法生成对象哈希(需 Git 2.29+ 版本支持):
|
||||||
|
|
||||||
|
`git init --object-format {{sha256}}`
|
||||||
|
|
||||||
|
- 创建裸仓库,适合用作 SSH 远程仓库:
|
||||||
|
|
||||||
|
`git init --bare`
|
24
pages.zh/common/git-merge.md
Normal file
24
pages.zh/common/git-merge.md
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# git merge
|
||||||
|
|
||||||
|
> 合并分支。
|
||||||
|
> 更多信息:<https://git-scm.com/docs/git-merge>.
|
||||||
|
|
||||||
|
- 将指定分支合并到当前分支:
|
||||||
|
|
||||||
|
`git merge {{分支名}}`
|
||||||
|
|
||||||
|
- 编辑合并说明信息:
|
||||||
|
|
||||||
|
`git merge --edit {{分支名}}`
|
||||||
|
|
||||||
|
- 合并分支,创建合并提交:
|
||||||
|
|
||||||
|
`git merge --no-ff {{分支名}}`
|
||||||
|
|
||||||
|
- 遇到冲突时中止合并:
|
||||||
|
|
||||||
|
`git merge --abort`
|
||||||
|
|
||||||
|
- 采用特定的策略进行合并:
|
||||||
|
|
||||||
|
`git merge --strategy {{策略}} --strategy-option {{策略选项}} {{分支名}}`
|
|
@ -1,16 +1,16 @@
|
||||||
# git pull
|
# git pull
|
||||||
|
|
||||||
> 从远程代码库拉取分支,并将其合并到本地代码库。
|
> 从远程仓库获取分支,并将其合并到本地仓库。
|
||||||
> 更多信息:<https://git-scm.com/docs/git-pull>.
|
> 更多信息:<https://git-scm.com/docs/git-pull>.
|
||||||
|
|
||||||
- 从默认的远程分支中拉取代码并执行合并:
|
- 从默认的远程仓库拉取代码并执行合并:
|
||||||
|
|
||||||
`git pull`
|
`git pull`
|
||||||
|
|
||||||
- 使用快进功能(快进到含义为:先清空暂存区,再执行合并,最后恢复暂存区),从默认的远程分支拉取代码并执行合并:
|
- 从默认的远程仓库拉取代码并采用变基策略实现合并(将你的本地提交“移植”到远程获取的分支上):
|
||||||
|
|
||||||
`git pull {{[-r|--rebase]}}`
|
`git pull {{[-r|--rebase]}}`
|
||||||
|
|
||||||
- 从给定的分支中拉取代码,并执行合并到对应分支:
|
- 从给定的远程仓库和分支中拉取代码,并合并到本地对应分支:
|
||||||
|
|
||||||
`git pull {{远程分支名}} {{本地分支名}}`
|
`git pull {{远程仓库名}} {{分支名}}`
|
||||||
|
|
36
pages.zh/common/git-push.md
Normal file
36
pages.zh/common/git-push.md
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# git push
|
||||||
|
|
||||||
|
> 推送提交到远程仓库。
|
||||||
|
> 更多信息:<https://git-scm.com/docs/git-push>.
|
||||||
|
|
||||||
|
- 将当前分支的本地更改推送到其默认的远程对应分支:
|
||||||
|
|
||||||
|
`git push`
|
||||||
|
|
||||||
|
- 将指定本地分支的更改推送到其远程对应分支:
|
||||||
|
|
||||||
|
`git push {{远程仓库名}} {{本地分支名}}`
|
||||||
|
|
||||||
|
- 将指定本地分支的更改推送到其远程对应分支,并将该远程分支设为该本地分支 push/pull 的默认目标分支:
|
||||||
|
|
||||||
|
`git push {{[-u|--set-upstream]}} {{远程仓库名}} {{本地分支名}}`
|
||||||
|
|
||||||
|
- 将指定本地分支的更改推送到指定的远程分支:
|
||||||
|
|
||||||
|
`git push {{远程仓库名}} {{本地分支名}}:{{远程分支名}}`
|
||||||
|
|
||||||
|
- 将所有本地分支的更改推送到指定远程仓库中各个对应分支:
|
||||||
|
|
||||||
|
`git push --all {{远程仓库名}}`
|
||||||
|
|
||||||
|
- 删除远程仓库中的分支:
|
||||||
|
|
||||||
|
`git push {{远程仓库名}} {{[-d|--delete]}} {{远程分支名}}`
|
||||||
|
|
||||||
|
- 删除没有本地对应分支的远程分支:
|
||||||
|
|
||||||
|
`git push --prune {{远程仓库名}}`
|
||||||
|
|
||||||
|
- 推送本地的新标签到远程仓库:
|
||||||
|
|
||||||
|
`git push --tags`
|
33
pages.zh/common/git-status.md
Normal file
33
pages.zh/common/git-status.md
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# git status
|
||||||
|
|
||||||
|
> 展示 Git 仓库中文件的变更情况。
|
||||||
|
> 列出与当前检出提交相比有修改、新增和删除的文件。
|
||||||
|
> 更多信息:<https://git-scm.com/docs/git-status>.
|
||||||
|
|
||||||
|
- 显示修改过但尚未暂存(以备提交)的文件:
|
||||||
|
|
||||||
|
`git status`
|
||||||
|
|
||||||
|
- 以简短形式输出:
|
||||||
|
|
||||||
|
`git status {{[-s|--short]}}`
|
||||||
|
|
||||||
|
- 显示暂存区与工作目录的详细变更信息:
|
||||||
|
|
||||||
|
`git status {{[-vv|--verbose --verbose]}}`
|
||||||
|
|
||||||
|
- 显示当前分支及其跟踪(上游)分支信息:
|
||||||
|
|
||||||
|
`git status {{[-b|--branch]}}`
|
||||||
|
|
||||||
|
- 以简短形式输出,同时包含分支信息:
|
||||||
|
|
||||||
|
`git status {{[-sb|--short --branch]}}`
|
||||||
|
|
||||||
|
- 显示当前贮藏区(stash)中的条目数量:
|
||||||
|
|
||||||
|
`git status --show-stash`
|
||||||
|
|
||||||
|
- 不显示未跟踪的文件:
|
||||||
|
|
||||||
|
`git status {{[-uno|--untracked-files=no]}}`
|
Loading…
Add table
Reference in a new issue