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

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.

主站蜘蛛池模板: 大新县| 新昌县| 汝城县| 广安市| 岳池县| 神木县| 富民县| 盐山县| 冀州市| 资中县| 南汇区| 荆门市| 宁海县| 正蓝旗| 花垣县| 子洲县| 藁城市| 安西县| 乳源| 曲松县| 香格里拉县| 平阳县| 广德县| 富阳市| 扎囊县| 江源县| 日土县| 千阳县| 图木舒克市| 垦利县| 青岛市| 东宁县| 梅州市| 新化县| 民丰县| 无极县| 大庆市| 西峡县| 德兴市| 天门市| 民县|