git 覆盖本地修改
When you learn to code, sooner or later you'll also learn about Version Control Systems. And while there are many competing tools in this space, one of them is the de facto standard used by almost everyone in the industry. It's so popular that there are companies that use its name in their branding. We're talking about Git, of course.
当您学习编码时,迟早也将了解版本控制系统。 尽管在这个领域有许多竞争性工具,但其中一个就是几乎每个行业内的人都在使用的事实上的标准。 它是如此流行,以至于有些公司在其品牌中使用了它的名字。 当然,我们在谈论Git。
While Git is a powerful tool, its power is well-hidden. There are some essential concepts that you need to understand to become really proficient with Git. The good news is that once you learn them, you'll hardly ever run into trouble you can't escape from.
虽然Git是强大的工具,但它的功能是隐藏的。 要真正精通Git,您需要了解一些基本概念。 好消息是,一旦您学习了它们,就几乎不会遇到无法逃脱的麻烦。
典型工作流程 (The Typical Workflow)
In a typical Git workflow you'll use a local repository, a remote repository, and one or more branches. Repositories store all the information about the project, including its entire history and all the branches. A branch is basically a collection of changes leading from an empty project to the current state.
在典型的Git工作流程中,您将使用本地存储库,远程存储库以及一个或多个分支。 存储库存储有关项目的所有信息,包括项目的整个历史记录和所有分支。 分支基本上是从空项目到当前状态的更改的集合。
After cloning a repository, you work on your local copy and introduce new changes. Until you push local changes to the remote repository, all your work is available only on your machine.
克隆存储库后,您将在本地副本上工作并引入新的更改。 在将本地更改推送到远程存储库之前,所有工作仅在计算机上可用。
When you finish a task, it's time to synchronize with the remote repository. You want to pull the remote changes to keep up with the project's progress, and you want to push the local changes to share your work with others.
完成任务后,就该与远程存储库进行同步了。 您希望提取远程更改以跟上项目的进度,并且希望推送本地更改以与他人共享您的工作。
当地变化 (Local Changes)
All is well when you and the rest of your team are working on totally separate files. Whatever happens, you won't be stepping on each other's feet.
当您和团队的其他成员正在处理完全独立的文件时,一切都很好。 无论发生什么,您都不会踩到对方的脚。
However, there are times when you and your teammates simultaneously introduce changes in the same place. And that's usually where the problems begin.
但是,有时您和您的队友会在同一位置同时进行更改。 这通常是问题开始的地方。
Have you ever executed git pull
only to see the dreaded error: Your local changes to the following files would be overwritten by merge:
? Sooner or later, everyone runs into that problem.
您是否曾经执行过git pull
才能看到可怕的error: Your local changes to the following files would be overwritten by merge:
迟早,每个人都会遇到这个问题。
What's more confusing he