From the course: Git for System Administration

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Rolling back changes

Rolling back changes - Git Tutorial

From the course: Git for System Administration

Start my 1-month free trial

Rolling back changes

- [Instructor] We haven't spent too much time talking about each stage of Git commits, as we haven't needed to. I'll skim it here, because we need to understand it in order to roll back changes. First, when we make changes to a file, that change is local but not stored on the repository yet, because we haven't committed it. Let's see this in action. Inside your GitProjectOne directory, edit the file named ourfirstfile.txt with an editor. Let's delete the second line. In Vim, I just place my cursor on it and hit the D key twice. Now save and exit, by pressing esc:x and hitting enter. We can cat the file and see that it has changed. We haven't committed this change to the repository yet, so it's just local. Git, however, knows we changed the file. Type in git diff and hit enter. This command, compares the current file on disk with the one in the repository. We see our deleted line in red. What we want to do is copy the version of the file in our project, which includes the deleted line,…

Contents