Ned的Git生存指南 ?
Welcome to Ned's Declassified Git Survival Guide! ? In this guide, you'll learn essential Git commands like git checkout
and git restore
to undo changes, git stash
to save uncommitted work temporarily, git cherry-pick
? to pull specific commits from one branch to another, and git reflog
to recover "lost commits". Whether you're fixing a bug ?, changing priorities because your manager decided that, or restoring deleted code, these commands will help you handle common real-case scenarios with confidence ?. So, let’s dive in and master Git together!
欢迎来到 Ned's Declassified Git Survival Guide!? 在本指南中,你将学习到关键的 Git 命令,如git checkout
和git restore
用于撤销更改,git stash
用于临时保存未提交的工作,git cherry-pick
?用于从一个分支中提取特定的提交,以及git reflog
用于恢复“丢失的提交”。无论是修复错误?,因为经理决定了优先级,还是恢复删除的代码,这些命令都将帮助你自信地处理常见的实际情况。所以,让我们一起深入学习和掌握 Git 吧!
This is what we'll learn today:
今天我们将学到以下内容:
Index ?
索引 ?
-
Episode 1: First Day of Work & Bugs
第1集:工作的第一天和错误
- Using
git checkout
to restore files from a previous commit. - 使用
git checkout
从先前的提交中恢复文件。 - Saving uncommitted changes with
git restore
. - 使用
git restore
保存未提交的更改。
- Using
-
Episode 2: We've Got a New Priority, Houston
第二集:休斯顿,我们有一个新的优先事项
- How to stash untracked files with
git stash
. - 如何使用
git stash
存储未跟踪的文件。 - Managing stashes and retrieving them when needed.
- 管理存储并在需要时检索它们。
- How to stash untracked files with
-
Episode 3: The CoolFeature Crisis!
第三集:CoolFeature危机!
- Using
git cherry-pick
to select and apply specific commits. - 使用
git cherry-pick
选择和应用特定的提交。
- Using
-
Episode 4: I Changed My Mind Drama
第四集:我改变了主意的戏剧
- Recovering deleted commits with
git reflog
. - 使用
git reflog
恢复已删除的提交。
- Recovering deleted commits with
-
Conclusion
结论
Episode 1: First Day of Work & Bugs
第一集:工作的第一天和错误
Let's say we're building a Map Application for your workplace, and we have the following folder structure:
假设我们正在为你的工作场所构建一个地图应用程序,并且我们有以下文件夹结构:
We refactor our main.tsx
file because we want MapsApp.tsx
to be our main application file, but we accidentally introduce a bug.
我们重构了我们的main.tsx
文件,因为我们希望MapsApp.tsx
成为我们的主应用程序文件,但我们不小心引入了一个错误。
We don't realize it and proceed to commit and push it to the remote repository:
我们没有意识到并继续提交并推送到远程仓库:
(In case you'r...