官术网_书友最值得收藏!

Undoing the changes

The nice thing about having old project states saved away is that we can go back to them.

For example, let's say we have made some changes in our file.txt file from moo cow to moo aardvark, as shown in the following screenshots:

If we want to revert a file to a previous state, undoing everything we've done to that file since a particular commit, we just use the git log command to find the identifier for that commit:

git log

This will lead us to our commit, as shown here:

Then, we use the git checkout command to undo our changes. To use the git checkout command, we just need to enter the commit and the filename and you will get to undo the changes, as shown here:

If we later change our minds, we can redo the changes in the same way. The ability to undo on the project level is great, but it's even more useful to make provisional changes to our code and then decide, once the changes are done, whether or not we really want them in our main code. That's what branches are for.

主站蜘蛛池模板: 电白县| 克拉玛依市| 张家界市| 宁都县| 象州县| 会理县| 习水县| 彭阳县| 比如县| 江永县| 南雄市| 江华| 锦屏县| 晋宁县| 泰安市| 灵石县| 叶城县| 金平| 茶陵县| 苏尼特左旗| 会昌县| 西盟| 天长市| 皮山县| 永寿县| 晋州市| 成安县| 开鲁县| 安多县| 金塔县| 横山县| 上林县| 信阳市| 西贡区| 长寿区| 博客| 新郑市| 定兴县| 游戏| 武强县| 醴陵市|