Git In-depth Git In-depth

Simple Git Commit Exercise

Check out a free preview of the full Git In-depth course:
The "Simple Git Commit Exercise" Lesson is part of the full, Git In-depth course featured in this preview video. Here's what you'd learn in this lesson:

After configuring their editor, students create a simple Git commit for this exercise. Nina takes questions from students. - https://github.com/nnja/advanced-git/blob/master/exercises/Exercise1-SimpleCommit.md

Get Unlimited Access Now

Transcript from the "Simple Git Commit Exercise" Lesson

[00:00:00]
>> Nina: Now we're gonna work on an exercise. And before we get started on this exercise, i want you to follow that first link. In the case that you have not set up your editor for working with Git on the command line.
>> Nina: One of the biggest frustrations that I see for developers when they're first working with Git, and why they sometimes hesitate to use Git on the command line, is kind of the default configuration.

[00:00:30] So git, you try to commit without -m, and it opens a text editor. And by default, it might be vim or something, you don't know how to close it. Yeah, so the first thing we need to do, go to that link, git.io/config-editor. And I'll give you guys a few minutes to set up your Git editor to point to one that you actually use.

[00:00:58] It can be Sublime Text, it can be VS Code, whatever tool you use, it's important that you set that up.
>> Nina: Once you're done with that setup, go to the next link, it's a markdown file with the exercise. And after you're done with that, another frustration, for example, you type git log on the command line, it opens a new window.

[00:01:22] You might not know how to quit, how to navigate it. So that's called a pager, and by default, it's set up to less. It's a Unix command line tool that helps you kind of quickly scroll through pages of information. When you're done with the exercise, check out, I wrote a little cheat sheet for using less, it's at git.io/use-less.

[00:01:49] Most importantly, it tells you how to quit, spoiler alert, it's the Q key, yes?
>> Speaker 2: Just a clarification, so head is just where you currently are. So it's a pointer to the current branch that you're on, right?
>> Nina: The current branch, in some cases, that could also be the current commit.

[00:02:13] But we'll go through that a little bit later. Just wanna make sure my answer's complete. But if you're on a branch, it points to the last commit in that branch.
>> Speaker 2: So when you clone,
>> Speaker 2: Remote repository or whatever, git repo. The head, by default, points to where?

[00:02:40]
>> Nina: When you clone a remote repository, it checks out the default branch, which in 99% of the cases is master, so.
>> Speaker 2: Like in GitHub, you can change it to something else, like to development or something, right?
>> Nina: Right, yeah, you can kind of browse around. But that doesn't change any of the values of the .git directory.

[00:03:05]
>> Speaker 2: Is it git that stores that default branch, or is it GitHub?
>> Nina: That I'm not sure about.
>> Speaker 2: I'd assume it's git, I'd assume it would be in the git repository.
>> Nina: Yeah, it's git, I wanna say it's possible to change the default branch. For example, you can delete the master branch, it's just a name.

[00:03:28] But I'm not sure of the exact mechanism of how git checks which one is the default. But I can look into that over the exercise.