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 checkoutgit restore用于撤销更改,git stash用于临时保存未提交的工作,git cherry-pick?用于从一个分支中提取特定的提交,以及git reflog用于恢复“丢失的提交”。无论是修复错误?,因为经理决定了优先级,还是恢复删除的代码,这些命令都将帮助你自信地处理常见的实际情况。所以,让我们一起深入学习和掌握 Git 吧!

This is what we'll learn today:

今天我们将学到以下内容:

Index ?

索引 ?

  1. 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保存未提交的更改。
  2. 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.
    • 管理存储并在需要时检索它们。
  3. Episode 3: The CoolFeature Crisis!

    第三集:CoolFeature危机!

    • Using git cherry-pick to select and apply specific commits.
    • 使用git cherry-pick选择和应用特定的提交。
  4. Episode 4: I Changed My Mind Drama

    第四集:我改变了主意的戏剧

    • Recovering deleted commits with git reflog.
    • 使用git reflog恢复已删除的提交。
  5. 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:

假设我们正在为你的工作场所构建一个地图应用程序,并且我们有以下文件夹结构:

Folder structure of React in Vite

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成为我们的主应用程序文件,但我们不小心引入了一个错误。

Commit with a bug in main.tsx

We don't realize it and proceed to commit and push it to the remote repository:

我们没有意识到并继续提交并推送到远程仓库:

Doing the commit process

(In case you'r...

开通本站会员,查看完整译文。

Home - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-05 14:39
浙ICP备14020137号-1 $Map of visitor$