We launched a new IT training category! Check out the 140+ courses now.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Working with check-in, checkout, and revert

From: Fundamentals of Software Version Control

Video: Working with check-in, checkout, and revert

Okay, we've got a Git repository inside of our directory g1 here. Before we start adding things, let's set two git configuration items which will help us make sure that all of our changes are marked with our name and our email. So we say git config user.name and git config user.email. No, that's not my actual email. And now we can put in some code.

Working with check-in, checkout, and revert

Okay, we've got a Git repository inside of our directory g1 here. Before we start adding things, let's set two git configuration items which will help us make sure that all of our changes are marked with our name and our email. So we say git config user.name and git config user.email. No, that's not my actual email. And now we can put in some code.

The content we're going to use is from the new project's haiku error message page. We're going to pick one that's happened to all of us before we started using Version Control. I'm going to create f1.c and main print f. With searching comes loss, and the presence of absence. "\My Novel\" not found.\n".

Now of course, this isn't going to ever happen to you again now that you started to use Version Control, but you know how that feels. So we'll save the file, and we'll exit. Now we'll add that to the repository in two steps. First, we have to tell Git to start tracking that file by saying git add f1.c, and we ask Git the status of our working set. It says there is a new file ready to be checked in. So now we'll add it to the repository, git commit, and you can see it created one file.

If we ask Git for the status, it says there is nothing new to commit. And if we ask Git for the log, you can see we have a message here that says there is our Initial check in commit message and three additional lines of information which we're going to look at here. The first line is the commit ID, or essentially changeset identifier. That's a 40-digit-long hexadecimal number, which is a GUID, or a Global Unique Identifier. Now, for most usage inside Git, you'll only need to type the first four or five characters of that GUID, so don't get scared by the fact that it's going to be starting to ask you to type in 40 digit numbers.

But you have to type in at least as much of that in order to be able to uniquely identify a changeset as necessary. So especially on your own system, it's probably four digits. When you start working with more people, it's probably five or six at the most. So now let's make a change so we can see Git's versioning in action. We'll once again open up f1.c, and we're going to change My Novel to Website, maybe a more appropriate message for the internet age. And now we're going to check it in again, but this time we're going to use an editor feature that's built into Git in order to do our commit message.

So we're going to say git commit -a, and Git opens up in this case, Vim, a editor that allows you to put in your commit message. So we're going to say Changed my novel to website, and since this is Vim, it understands all those wonderful VI commands that you might know and love. In this case, what I do is I hit the Escape key and then I type :wq to Save it and Quit, and now it does the commit. And if we do git log, you can see now we have two changes, both our Initial check in and Changed my novel to website.

If you just want to see the changeset IDs and the comments, you can say git log --one line --all, and now we have--you can see the first seven digits of each one of those changeset IDs and the commit message. So now let's make another change and then look at it and decide if we want to roll it back. So once again, we're going to open up f1.c, and we're going to change Website to Webpage, and we're going to Save the file. Now, if we want to see the difference between our working set and what's in the repository, we can say git diff, and you can see it shows the one line has changed from website to web page.

Now, this show the difference with all files that are currently changed in the working set. If you want to see changes just for a single file, you can say git diff and just put in the file name. Now, in our case it's going to be exactly the same, but if you had 25 files, that might generate quite a bit of output. You can also ask for the differences between the working set and a specific changeset. So if we do git log, we can see we've got our two change sets. Let's ask for the difference between our working set and not the most recent one where we changed My Novel to Website, but the initial one where initially we checked it in and where we had My Novel.

So we'll say git diff, and we're going to put in 87b53, and we'll see what happens. So now you can see the difference between that commit which we called our Initial check in and the current state of our working set. You can see our current working set in green here says Webpage and the Initial check in said My Novel. Now, your changeset IDs are going to be different than these. You'll need to run git log on your system and type in the first five digits of the actual IDs on your system, because GUIDs are partially generated by the Mac address for your Ethernet adapter in your computer and so it will be clearly different than the system on which we're recording this.

So now let's roll back to our most recent commit. So we'll say git checkout HEAD f1.c. If we type f1.c, you can see we're back to Website. You can also revert to any particular revision, not just the topmost one, by using the checkout command. So we'll say git log, and now we're going to revert back to the initial one, so we're going say git checkout 87b53 f1.c, and now if we type f1.c, you can see we're back to My Novel.

Note, none of the changes in your repository have been lost. You're just updating the working set to the one that you want. So for example, we can go back to git checkout HEAD f1.c, and we're back to Website. All right, that's the basic working flow of checking in, checking out, and reverting with Git. Let's move on to tagging and labeling with Git.

Show transcript

This video is part of

Image for Fundamentals of Software Version Control
Fundamentals of Software Version Control

49 video lessons · 12407 viewers

Michael Lehman
Author

 
Expand all | Collapse all
  1. 2m 12s
    1. Welcome
      56s
    2. What you should know before taking this course
      23s
    3. Using the exercise files
      53s
  2. 25m 8s
    1. Overview of software version control
      2m 51s
    2. Understanding version control concepts
      5m 14s
    3. Demo one: Getting started
      11m 1s
    4. Demo two: Handling the "oops"
      6m 2s
  3. 11m 3s
    1. The history of version control
      3m 44s
    2. Terminology
      4m 27s
    3. Exploring centralized vs. distributed systems
      2m 52s
  4. 28m 42s
    1. Getting files in and out of a repository
      4m 38s
    2. Saving changes and tracking history
      2m 47s
    3. Reverting to a prior version
      1m 42s
    4. Creating tags and labels
      1m 5s
    5. Branching and merging
      4m 10s
    6. Exploring workflow integration and continuous builds
      2m 46s
    7. Using graphical user interface (GUI) tools
      2m 39s
    8. Integrating a version control system with an integrated development environment (IDE)
      2m 50s
    9. Examining shell integration
      3m 26s
    10. Looking at forward and reverse integration
      2m 39s
  5. 25m 59s
    1. Installation and setup
      3m 31s
    2. Creating a repository and a project
      5m 10s
    3. Working with check-in, checkout, and revert
      6m 12s
    4. Tagging
      1m 34s
    5. Branching and merging
      5m 32s
    6. Working with GUI clients and IDE integration
      4m 0s
  6. 16m 13s
    1. Installation and setup
      55s
    2. Working with check-in, checkout, and revert
      9m 34s
    3. Tagging
      1m 7s
    4. Branching and merging
      4m 37s
  7. 26m 41s
    1. Installation and setup
      3m 47s
    2. Creating a repository and a project
      6m 15s
    3. Working with check-in, checkout, and revert
      8m 31s
    4. Tracking history and tagging
      2m 15s
    5. Branching and merging
      5m 53s
  8. 19m 25s
    1. Installation and setup
      3m 1s
    2. Creating a repository and a project
      1m 6s
    3. Working with check-in, checkout, and revert
      6m 39s
    4. Tagging
      2m 13s
    5. Branching and merging
      3m 44s
    6. Working with GUI clients and IDE integration
      2m 42s
  9. 16m 54s
    1. Installation and setup
      1m 48s
    2. Creating a repository and a project
      59s
    3. Working with check-in, checkout, revert, and tracking history
      6m 9s
    4. Tagging
      1m 50s
    5. Branching and merging
      4m 29s
    6. Exploring GUI and shell integration
      1m 39s
  10. 3m 38s
    1. Selecting a software version control that is right for you
      2m 30s
    2. Next steps
      1m 8s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Fundamentals of Software Version Control.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.