Git命令速查表—中英文对照版

最近使用版本控制比较多,在此使用Chatgpt整理了一份Git常用命令中英文对照表,方便需要时查找。

01:设置与初始化(Setup & Init)

:02Git 命令英文说明中文说明
git config --global user.name "[firstname lastname]"Set a name that is identifiable for credit when reviewing version history.设置用户名,用于提交记录署名。
git config --global user.email "[valid-email]"Set an email address that will be associated with each history marker.设置邮箱,用于提交记录的邮箱信息。
git config --global color.ui autoSet automatic command line coloring for Git for easy reviewing.启用命令行自动颜色显示,方便查看。
git initInitialize an existing directory as a Git repository.在当前目录初始化 Git 仓库。
git clone [url]Retrieve an entire repository from a hosted location via URL.从远程仓库克隆到本地。

02:暂存与快照(Stage & Snapshot)

Git 命令英文说明中文说明
git statusShow modified files in working directory, staged for your next commit.显示已修改文件及暂存状态。
git add [file]Add a file as it looks now to your next commit (stage).将文件添加到暂存区。
git add . Adds / stages all of the files in the current directory. 将当前目录和所有子目录中所有已修改的和新的(未跟踪的)文件添加到暂存区(又称索引),从而准备将它们包含在下一个 git commit 中
git reset [file]Unstage a file while retaining the changes in working directory.将文件从暂存区移除但保留修改。
git diffDiff of what is changed but not staged.显示已修改但未暂存的差异。
git diff --stagedDiff of what is staged but not yet committed.显示已暂存但未提交的差异。
git commit -m "[message]"Commit your staged content as a new commit snapshot.提交暂存区内容生成快照。

03:分支与合并(Branch & Merge)

Git 命令英文说明中文说明
git branchList your branches. A * will appear next to the currently active branch.列出分支,当前分支前有 * 标记。
git branch [branch-name]Create a new branch at the current commit.创建新分支。
git checkout [branch]Switch to another branch and check it out into your working directory.切换到指定分支。
git merge [branch]Merge the specified branch’s history into the current one.将指定分支合并到当前分支。
git logShow all commits in the current branch’s history.显示当前分支的提交历史。

04:共享与更新(Share & Update)

Git 命令英文说明中文说明
git remote add [alias] [url]Add a git URL as an alias.添加远程仓库地址别名。
git fetch [alias]Fetch down all the branches from that Git remote.获取远程仓库所有分支。
git merge [alias]/[branch]Merge a remote branch into your current branch.将远程分支合并到当前分支。
git push [alias] [branch]Transmit local branch commits to the remote repository branch.推送本地分支到远程分支。
git pullFetch and merge any commits from the tracking remote branch.拉取并合并远程最新提交。

05:跟踪路径变化(Tracking Path Changes)

Git 命令英文说明中文说明
git rm [file]Delete the file from project and stage the removal for commit.删除文件并暂存删除操作。
git mv [old-path] [new-path]Change an existing file path and stage the move.移动或重命名文件并暂存。
git log --stat -MShow all commit logs with indication of any paths that moved.显示提交日志并标出文件路径变化。

06:临时提交(Temporary Commits / Stash)

Git 命令英文说明中文说明
git stashSave modified and staged changes.保存已修改或暂存的更改。
git stash listList stack-order of stashed file changes.显示暂存的更改列表。
git stash popWrite working from top of stash stack.恢复最新一次保存的更改。
git stash dropDiscard the changes from top of stash stack.丢弃最新一次保存的更改。

07:重写历史(Rewrite History

Git 命令英文说明中文说明
git rebase [branch]Apply any commits of current branch ahead of specified one.将当前分支提交应用到指定分支之后。
git reset --hard [commit]Clear staging area, rewrite working tree from specified commit.清空暂存区并回退到指定提交。

08:检查与比较(Inspect & Compare)

Git 命令英文说明中文说明
git logShow the commit history for the currently active branch.显示当前分支提交历史。
git log branchB..branchAShow the commits on branchA that are not on branchB.显示 branchA 中但不在 branchB 的提交。
git log --follow [file]Show the commits that changed file, even across renames.显示文件的修改历史(包括改名)。
git diff branchB...branchAShow the diff of what is in branchA that is not in branchB.显示 branchA 相对 branchB 的差异。
git show [SHA]Show any object in Git in human-readable format.以可读格式显示对象详细信息。

09:忽略文件模式(Ignoring Patterns)

Git 命令 / 文件内容英文说明中文说明
git config --global core.excludesfile [file]System-wide ignore pattern for all local repositories.设置全局 .gitignore 文件。
.gitignore 内容示例:Save a file with desired patterns as .gitignore with either direct string matches or wildcard globs.将匹配规则保存到 .gitignore 文件中,可使用直接匹配或通配符。
示例:logs/*.notespattern*/Example patterns to ignore.忽略日志目录、.notes 文件以及 pattern 开头的目录。

欢迎评论交流,如果文章对您有帮助,可以支持下博主。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇