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

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.

主站蜘蛛池模板: 安庆市| 汉川市| 临海市| 临湘市| 乐安县| 柳林县| 贺兰县| 孝昌县| 清徐县| 乐都县| 江陵县| 达拉特旗| 资阳市| 枞阳县| 南木林县| 吉首市| 澎湖县| 邢台县| 桦川县| 乃东县| 望城县| 蒙自县| 吴忠市| 娱乐| 柳江县| 古蔺县| 新安县| 海盐县| 定襄县| 罗甸县| 邵东县| 通州区| 广饶县| 盐池县| 尤溪县| 平阴县| 安康市| 镇赉县| 丹寨县| 双江| 丹棱县|