Git And Github Complete Guide

Tags: Git

Complete Git and GitHub guide (23 HOURS) - Master all Git features: commits, branches, merging, rebasing and squashing

Last updated 2022-01-10 | 4.7

- Deeply understand how Git works under the hood
- Use Git not just in terminal but also in graphical user interfaces like GitHub Desktop
- SourceTree
- Visual Studio Code
- Learn different GIt objects - blobs
- trees
- commits and annotated tags

What you'll learn

Deeply understand how Git works under the hood
Use Git not just in terminal but also in graphical user interfaces like GitHub Desktop
SourceTree
Visual Studio Code
Learn different GIt objects - blobs
trees
commits and annotated tags
Create local and remote Git repositories
Perform basic and advanced Git operations
Learn how to perform rebasing and merging of the branches
Learn what is pull request and how to create pull request at GitHub
Contribute to public repositories using technique of forks and pull requests from the forked repository
Understand what is semantic versioning and how to use Git Tags in order to create software release versions
Learn advanced Git operations - squashing
cherry-picking
amending
reverting commits.

* Requirements

* We will start from the very beginning
* from basic Git features and move on to advanced techniques and operations
* Prepare only your Mac
* Windows or Linux/Unix computer. Anything will work.
* If you are new to Git
* please start from the very beginning: learn how Git works and how to perform basic operations (git add
* git commit
* git branch)
* If you are advanced Git user I highly recommend you to watch "How Git works under the hood" section and then jump to advanced Git features like squashing
* cherry-picking etc.

Description

This course is all about Git and GitHub.

Understand HOW Git works and learn all Git features from basic commits to squashing and rebasing.

  • Blobs, Trees, Annotated tags, SHA1 hashes

If those terms are new to you - jump in and you will learn all about Git internals and afterwards practice basic and advanced Git features using multiple practice activities.

Become a master of Git, GitHub, GitHub Desktop, SourceTree and Visual Studio Code.


This is the most complete practical Git and GitHub guide here on Udemy that includes tons of practical activities. Most important is that you will learn how Git works and knowing it you will be able much more easier use Git features and fix mistakes in your development workflow. You can have zero knowledge about Git and GitHub. All will be taught from scratch, from basic to advanced features. If you want to get deep knowledge of Git and GitHub this course is for you!


We will start by exploring internal structure of the Git repository. You will learn that Git has 4 types of objects: blobs, trees, commits and annotated tags. Each object has unique SHA1 hash. Also all objects are stored in the folders. Every object has just single reference to it - SHA1 hash. Files are stored in blobs. Filenames are stored in other Git objects called trees.

I will explain you how to create new Git objects without using git commit and git add. After creating Git object in the Git repository you will checkout it to staging area and working directory (opposite direction to traditional Git flow)

Afterwards we will jump into tons of practice activities and use different Git and GitHub features

In practice sections you will perform multiple practice Git activities:

  1. Initialize new Git repository

  2. Make changes, add them to staging area and commit

  3. Create branches, checkout branches and merge branches

  4. Perform fast-forward and 3-way merges of the branches

  5. Resolve merge conflicts

  6. Move into detached HEAD state and make experimental commits there

  7. Perform rebasing of the branches

You will also learn and practice different GitHub features

  1. Connect local and remote repositories

  2. Pushing, fetching and pulling operations

  3. Open Pull Request

  4. Merge Pull Request

  5. Add software versions using Git Tags

  6. Create forks from other repositories

  7. Contribute to public repositories using technique of forks and pull requests

  8. Perform rebasing with squashing

You will use not just terminal and shell commands for performing Git operations. In parallel you will also use GUI applications that simplify routine day-by-day Git operations:

  • GitHub Desktop

  • SourceTree

  • VisualStudio Code

With this course you will get lifetime-long access to almost 200 lectures and tens of practical exercises. After the course you will become a guru of Git and GitHub and will be able easily perform basic and advanced Git tasks.

But most important is that you will UNDERSTAND Git.

You will also get 30-days money-back guarantee. No questions asked!

Don't wait and join the course now!

Who this course is for:

  • You could be either complete beginner or experienced developer with years of usage of Git
  • You may know how to USE Git but you may not know HOW Git works
  • If you want to learn HOW and WHY Git and GitHub work - this course is for you!

Course content

21 sections • 292 lectures

Welcome and Course Overview Preview 05:24

Welcome to the Git course! In this introduction lecture I will give you a quick overview of the course and tell you what will be covered in different sections.

Let's get connected! Join the Learning Community Preview 00:26

Section 1 Introduction Preview 01:28

Introduction for the first section of the course where I will compare Git and GitHub

PDF - Introduction to the Git and GitHub Preview 00:02

Git vs GitHub Preview 05:30

What is the difference between Git and GitHub? Let's discuss it in this lecture!

Section 2 Introduction Preview 00:42

In this section you will install Git on your computer and configure Shell

Installing Git on MacOS Preview 02:24

If you use Mac OS this lesson is for you. I will show you how to install Git on Mac.

Installing Git on Windows Preview 10:41

If you use Windows, this lecture is for you. I will show you here how to install Git on Windows.

Installing Git on Linux Preview 08:20

Installation of Git on Linux is very simple. In this lecture I will demonstrate you how to do it.

Installing iTerm2 on the Mac Preview 05:36

If you use Mac I highly suggest you to install custom Terminal called iTerm2 and use it instead of built-in Terminal.

Installing custom shell Z-Shell on the Mac Preview 05:32

Along with iTerm2 it's a nice idea to install also custom shell called Z-Shell. In this video I will guide you through this process.

Section 3 Introduction Preview 00:43

In this course you and I will heavily use Shell. In this section I will show you basic commands that you will use for different operations like creation of new folders, files etc.

PDF - Basic Shell Commands Preview 00:02

Shell commands - directory management Preview 09:38

In this lecture I will demonstrate you how to perform directory management in Shell.

Shell commands - file management - PART 1 Preview 08:59

In this lecture I'll demonstrate you how to perform file management using Shell. You will learn how to read files the how to edit files using such editors like Nano.

Shell commands - file management - PART 2 Preview 08:25

In this lecture we will continue discussion of file management commands in Shell and the I'll demonstrate you some examples.

Section 4 Introduction Preview 00:57

It is very important to understand how Git works under the hood. That's why let me quickly go over topic we will discuss in this large section.

PDF - How Git works under the hood Preview 00:02

Initialize new Git repository Preview 04:12

First step in the management of repositories is the creation of the new Git repository. In this lecture I will show you how to perform initialisation of the new Git repository.

Overview of .git folder Preview 04:01

After initialisation of the new Git repository you will see that Git will create .git folder. And in this lecture I'll show you contents of this .git folder.

Git object types Preview 03:02

Let me now explain you which object types Git could store in the  .git folder.

Writing new Git object with git hash-object Preview 06:45

It is possible to insert the new object into the Git repository with git hash-object command. And in this lecture I'll demonstrate you how to perform this task yourself manually.

JSON vs Git database Preview 03:57

Structure of the Git repository is very similar to JSON structure. And in this lecture I'll demonstrate you what are the similarities and what are the differences between JSON and Git repository.

What is hash function Preview 03:52

Every object that is stored in the Git repository is stored with unique name. And this unique name is generated using SHA1 hash function. In this lecture I'll tell you what is hash function and how it works.

Hash functions overview Preview 03:29

There are different hash functions available. In this lecture I will explain you difference between some hash functions and tell you which hash function is used in Git.

SHA1 Hash Function Preview 10:18

SHA1 hash function generates hash that is 160 bits long. And exactly this hash function is used in Git for creation of the unique id for every object like Git blob, tree or commit.

How many files Git could store Preview 04:09

You already know that Git creates unique hashes for every file that is stored in the repository. And here I want to explain you how many files in total Git could store in the Git repository.

Probability theory in Dice game Preview 04:11

Let me know get the back to the very simple Dice game and explain you some basics of probability theory and how it could be applied to Git.

Git hash collision probability Preview 05:56

Let me know talk about the probability of getting exactly the same numbers in the Dice game and same hashes in the Git repository

Next lecture is OPTIONAL Preview 00:27

More details on hash collision probability (OPTIONAL) Preview 27:13

Exploring Git objects with git cat-file command Preview 05:24

It is possible to read Git objects using specific command that is called git cat-file. With this command you are able to read the contents of specific object in the Git repository. Also you are able to read the type of the object and it's length.

Create new Git Blob based on the file Preview 07:56

In this lesson I'll demonstrate you how you are able to create new Git blob in the Git repository from the contents of specific file.

Git blobs don't store filenames Preview 02:40

In fact Git does not store file names along with every blob. Every blob has unique filename that  is based on the SHA1 hash of this file. That's why Git needs to store filenames somewhere else.

Contents of Git objects Preview 10:14

Every Git object has specific structure. Git stores following data in every object: type, length, delimiter and content.

What we have so far Preview 01:56

We have just discussed some internals of Git and now you know how Git stores every object in the Git repository.

Tree objects in Git Preview 02:41

There are four different types of Git objects. They are blob, tree, commit and annotated tag. Let me now explain you what is the purpose of the tree objects in Git.

Git object permissions Preview 02:25

Git tree object stores actual filenames and SHA1 hashes for every blob. Also it stores file permissions of every blob. In this lecture I want to tell you about the different possible object permissions.

Creating Git Tree object Preview 09:52

You could create new Git tree object manually. Now let me demonstrate how you are able to do that.

Examining Tree Object Preview 04:52

Let's now examine contents of the Git tree object.

Working directory, Staging area and Git repository Preview 01:55

Let me know talk about the difference between working directory, staging area and git repository.

Overview of current files distribution Preview 03:50

Let me now show you where all files that we have created before are located in terms of working directory, staging area and Git repository.

Git read-tree Preview 03:51

Let me know show you how you're able to use such command as git read-tree.

Read files in the staging area using git ls-files Preview 01:58

Sometimes it's useful to read files that are located in the staging area. You could read the files in the staging area using command git ls-files.

Git checkout-index Preview 03:11

You could move files from the Git repository to the staging area using command git checkout-index.

How many folders could be created for objects Preview 02:20

Let's now calculate how many different folders could be created in the Git repository

Section Summary Preview 04:20

Let's now summarise what we have discussed in this large section dedicated to the Git internals.

Section 5 Introduction Preview 00:53

In this section we will talk about the basic Git operations. I will explain you how to create a new commit, how to perform management of the git repository, how to add the files to the staging area, how to remove files from the staging area and so on.

PDF - Basic Git operations Preview 00:02

What is Commit Preview 03:59

Let me now explain you what is commit and why it is needed.

Configure Git author name and email Preview 03:50

Before starting using Git you should configure global Git name and email that will be appended to all commits you will make.

Creating first commit Preview 04:00

Let's now finally create you very first commit in your very first git Project

Exploring commit object Preview 05:36

We have just created the very first commit in the Git repository. Now it's a good time to explore contents of this commit object.

Current project state overview Preview 05:08

Now let me briefly overview current state of our project.

Basic Git commands Preview 03:34

We have just created very first commit in the repository. Now let's talk about basic Git comments like git status, git log and git checkout.

Adding new file to working directory Preview 05:43

Now let me demonstrate you how you're able to add the new file to the working directory in Git.

Git files lifecycle Preview 08:37

Every file has its own lifecycle and there are several possible locations where files could be stored in Git. File could be located in the working directory, staging area or repository.

Stage file Preview 01:59

If file is already located to in the working directory you are able to stage this file and move it to staging area as well. This process is called "stage file".

Unstage file using git rm Preview 02:57

If specific file is already present in the Git staging area you are able to remove it from the staging area using git rm command

Commit changes Preview 02:07

If some files are already present in the working directory and staging area it's a good time to commit them. And here I'll explain you what happens when you commit changes.

Exploring changes in Git repository Preview 07:53

As you see every file in Git could be either untracked or modified, or staged, or unmodified. Let's now explore changes in our Git repository.

Current diagram of Git repository Preview 06:15

At the moment in the Git repository there are two different commit objects, two different tree objects and three different blobs. Let me explain you all of that using a graphical diagram.

Section 6 Introduction Preview 01:12

In this section we will talk about the Git branches and Git HEAD. I will explain you how to create a new branch of how to switch between different branches

PDF - Git branches and HEAD Preview 00:02

Most common Git operations Preview 06:17

No I will explain you how to move files between working directory, staging area and Git repository. I will show you how to use following commands: git add, get commit and git checkout.

Overview of the current project state Preview 01:23

Let's explore the structure of the project at this moment of time. At the moment there are three different blobs, two different trees and 2 commits.

Installing GitHub Desktop Preview 03:36

GitHub Desktop is a very useful GUI application and using the GitHub Desktop you could easily manage multiple Git repositories and perform different Git actions.

GitHub Desktop Overview Preview 04:58

Let me now explain you most common features of the GitHub Desktop and I'll explain you how to add Git repository and how to explore it inside of the GitHub Desktop

What is branch in Git Preview 06:44

Branch in Git is a simple pointer to specific commit and in this lecture I'll explain you features of the branch in Git

What is HEAD in Git Preview 05:31

In Git there is specific term called HEAD and in this lecture I will explain you what is HEAD and how it is used in Git

Third commit Preview 05:22

At the moment there are two different commits and now it's a good time to create one more commit and afterwards we will explore changes in Git repository after this third commit

Git repository changes after third commit Preview 07:12

We have just created one more commit in the Git repository and now let's explore what was changed in the repository after this last commit. There will be actually one more commit object and one more tree object.

Checkout specific commit Preview 13:49

Now you know that the HEAD points to the currently checked out branch. In this lecture let me show you how you could checkout specific commit by using its SHA1 hash.

Why do we need branches Preview 10:36

Let me now explain you why we need branches. Branches are needed if you want to work on multiple features in the same project in parallel. And branch is simply pointer to the specific commit.

Git branches management Preview 03:04

Let me now quickly explain you how you could manage multiple branches in the same Git repository.

Create new branch Preview 07:20

You could quickly and easily create a new Git branch by using the git branch command. Also you could use a git checkout command with option -b in order to create new branch and immediately switch to this newly created branch.

Commit changes in the new branch Preview 04:35

Let's now create new branch and switch to it. Afterwards lets make some changes there and commit those changes.

Explore commit in the new branch Preview 05:31

We have just created a new branch and made some changes in this new branch. Afterwards we have committed those changes. Now let's explore changes made in the last commit in the new branch.

Git reuses blobs with the same contents Preview 07:34

Now let me talk about very important Git feature. Git re-uses blobs with the same content. There is no need to create new blob if there is already blob with the same contents in Git repository.

Section 7 Introduction Preview 00:55

Cloning remote repository Preview 06:01

Exploring contents of the cloned repository Preview 07:52

Unpacking Git objects Preview 04:06

Exploring cloned repository in GitHub Desktop Preview 05:18

Installing text editor Visual Studio Code Preview 02:45

Exploring Visual Studio Code Preview 06:05

Commit changes in the cloned repository Preview 11:34

Git diff command Preview 13:56

Overview of the changes Preview 03:43

Section 8 Introduction Preview 01:14

PDF - Merging branches Preview 00:01

Why branches merging is needed Preview 03:27

Fast forward merge Preview 04:15

Merging process Preview 01:53

Fast forward merge in action Preview 06:57

3-way merge Preview 05:59

Performing 3-way merge Preview 12:38

Observing Git repository after 3-way merge Preview 06:40

Installing SourceTree Preview 04:00

SourceTree in action Preview 06:34

What is merge conflict Preview 03:05

Creating merge conflict Preview 09:48

Observing conflicts in staging area and working directory Preview 06:44

Resolving merge conflict in Terminal Preview 03:00

Resolving conflicts in VS Code Preview 09:00

Section 9 Introduction Preview 00:55

PDF - GitHub and remote repositories Preview 00:02

What is Git hosting service Preview 03:35

Creating GitHub account Preview 03:32

Now default branch for new repositories at GitHub is "main" Preview 00:16

Exploring first repository at GitHub Preview 11:00

Creating another commit at GitHub Preview 02:56

Creating new branch at GitHub Preview 01:25

Making changes in the new branch Preview 04:22

Cloning remote repository Preview 05:14

What is remote repository Preview 02:55

How remote repository empowers collaboration Preview 04:03

Section 10 Introduction Preview 01:35

PDF - Git push, fetch and pull Preview 00:02

Overview of the push, fetch and pull Git commands Preview 06:15

What is origin Preview 04:17

List remote and local branches Preview 03:04

What is tracking branch Preview 04:59

Checkout remote branch Preview 03:55

Git remote show origin Preview 03:08

Git fetch in action Preview 06:22

Git pull is 2-step process Preview 03:54

How to perform git pull Preview 05:08

What is FETCH_HEAD Preview 08:24

Git pull with fast forward merge Preview 07:37

Fetch remote changes manually Preview 09:09

Merge FETCH_HEAD manually Preview 06:05

Resolving conflicts during Git pull Preview 11:58

Pushing to remote repository Preview 09:27

Commit under another author Preview 02:42

Remote and local branches are in sync now Preview 03:34

Create remote branch based on local branch Preview 08:52

Update tracking statuses of the branches Preview 07:59

Remove remote branch using local terminal Preview 03:52

Git show-ref Preview 04:24

Section 11 Introduction Preview 01:03

PDF - Pull requests Preview 00:01

Collaboration between contributors Preview 04:29

What is pull request? Preview 02:35

Why pull request was named pull request Preview 06:11

Pull request or Merge request Preview 04:55

Pull request step-by-step Preview 07:49

Create new repository at GitHub Preview 06:53

Changing author of the last commit Preview 02:32

Pushing branch to remote Preview 05:00

Open pull request Preview 07:30

Adding comments and approving pull request Preview 09:24

Creating and publishing new branch using GitHub Desktop Preview 05:29

Signing in to GitHub in the GitHub Desktop Preview 01:24

Creating and merging pull request Preview 09:13

Adding new collaborator under GitHub Preview 03:55

Exploring own GitHub account Preview 04:49

Opening and merging PR by collaborator Preview 06:36

By default merging is allowed without approvals Preview 02:23

Configure protected branch rule Preview 04:18

Merging after required approve Preview 02:56

Exploring pull requests in the public repositories Preview 05:58

Working with issues at GitHub Preview 11:30

Section 12 Introduction Preview 00:50

PDF - Forks and contribution to the public repositories Preview 00:03

Creating Fork Preview 04:46

How to sync changes from the parent repository Preview 05:13

Adding new upstream remote repository Preview 02:04

Fetching changes from upstream Preview 02:26

Synchronizing changes from upstream Preview 10:55

How to open pull request from the forked repository Preview 02:32

Plan for creating pull request from the forked repository Preview 01:59

Removing repository collaborator Preview 02:07

Forking repository Preview 03:00

Committing changes in the forked repository Preview 03:17

Open pull request from the forked repository Preview 04:31

Approving and merging pull request from the forked repository Preview 11:43

Section 13 Introduction Preview 00:54

PDF - Git Tags Preview 00:01

Git tags overview Preview 03:16

Staging vs Production Preview 06:52

Semantic versioning Preview 11:08

Lightweight vs Annotated tags Preview 04:23

Creating lightweight tags Preview 09:32

Creating annotated tag Preview 02:50

Exploring git tag object Preview 03:04

Pushing tags to remote Preview 10:19

Section 14 Introduction Preview 01:26

PDF - Rebasing Preview 00:01

Introduction to Rebasing Preview 01:33

Merging vs Rebasing Preview 05:13

How to perform rebasing Preview 01:56

Rebasing - STEP 1 Preview 02:48

Rebasing - STEP 2 Preview 02:39

Creating new repository Preview 02:15

Creating feature branch and making changes Preview 04:50

Rebasing feature branch on top of master branch Preview 03:05

Completing rebasing by performing merging Preview 01:55

Exploring graph and commits in SourceTree Preview 05:09

Deleteing feature branch and pushing to remote Preview 01:38

Section 15 Introduction Preview 01:11

PDF - Ignoring files in Git Preview 00:02

Introduction go Git ignore Preview 02:18

Git file statuses - untracked, tracked and ignored Preview 02:07

Basic gitignore rules Preview 08:01

Pushing repository with ignored files to remote Preview 02:36

Committing previously ignored file Preview 02:53

Ignore previously committed file Preview 04:08

Git ignore common practices and templates Preview 05:31

Section 16 Introduction Preview 01:23

PDF - Detached HEAD Preview 00:01

Detached HEAD state Preview 04:22

Making experimental commits in detached HEAD state Preview 08:27

Retaining changes made in the detached HEAD state Preview 08:03

Section 17 Introduction Preview 00:50

Cloning one of the public repositories Preview 03:13

If "git lg" command is not available Preview 00:07

Git log options - oneline, graph, stat Preview 05:41

Git shortlog Preview 01:43

Filtering commits by author or keyword Preview 02:51

Pretty formatting of git log Preview 03:06

Filter out merge commits in git log Preview 03:04

Git reset Preview 10:17

Git revert Preview 08:32

Modifying last commit using amend option Preview 03:51

Cherry-picking commits Preview 05:52

Reflog - log of all Git operations Preview 07:12

Stashing changes using terminal Preview 05:25

Stashing using GitHub Desktop Preview 02:24

Garbage collection Preview 03:19

Squashing of commits at GitHub Preview 07:58

Interactive rebasing with squashing in the local repository Preview 07:39

Git development workflow Preview 06:19

Section 18 Introduction Preview 01:32

Creating simple website using GitHub Pages Preview 04:21

Hosting any Repository using GitHub Pages Preview 08:26

Creating basic React application Preview 09:49

Preparing React application for publish to the GitHub Pages Preview 08:42

Fixing error with cached credentials by using SSH instead of HTTPS Preview 10:42

Verifying React GitHub Page Preview 07:26

Configuring custom domain for GitHub Pages Preview 10:57

Creating static GitHub Page using markdown Preview 04:58

Section 19 Introduction Preview 01:48

PDF - Git Hooks Preview 00:01

Normal Git workflow without Hooks Preview 03:08

What are Git Hooks Preview 07:28

How Git Hooks could be used on practice Preview 05:06

Using pre-commit Hook Preview 13:18

Enabling post-commit Hook Preview 04:48

Disabling rebasing using pre-rebase Hook Preview 06:55

Match authors Email against Regular Expression Preview 07:21

Local Git Hooks are NOT pushed to the remote Preview 07:17

Cleaning up Local Git Hooks repository Preview 05:13

Initializing new Node.js project Preview 07:53

Installing Jest NPM package for testing Preview 03:23

Adding mult and sum modules with tests Preview 09:48

Which Husky version to install Preview 00:06

Using pre-commit NPM package for automation of the pre-commit hook Preview 07:25

Cloning remote repository and verifying pre-commit hook Preview 04:11

Replacing pre-commit NPM package with husky Preview 05:54

Skipping all Git Hooks using --no-verify option Preview 04:43

Introduce linter and run linter in the pre-commit Hook Preview 14:06

Introducing lint-staged package for checks only of the staged files Preview 06:29

Verifying selective linting and testing using lint-staged Preview 04:46

Adding post-commit Hook Preview 03:35

Verifying commit message using commitlint Preview 09:39

Git Hooks Summary Preview 03:01

Git Crash Course Overview Preview 01:49

Installing Git Preview 01:07

Initializing new Git Repository Preview 03:47

Git Object Types Preview 01:18

Hashes of the Git Objects Preview 01:31

Adding changes to the Staging Area Preview 07:16

Configuring Git author name and email Preview 03:47

Committing changes Preview 02:58

Exploring commits history Preview 05:45

Basic Git Commands Preview 02:05

Checking out commits and branches Preview 04:22

File tracking statuses in Git Preview 03:26

Staging and Committing changes using one command Preview 02:45

Branches and merging of the branches Preview 06:04

Branches merging in action Preview 07:45

Exploring commits tree using graph option Preview 01:54

GitHub and repository hosting services Overview Preview 02:39

Creating remote repository at GitHub Preview 02:30

Pushing from the local repository to remote Preview 03:36

Committing at GitHub and pulling to the local repository Preview 02:35

Exploring and reading Git Objects Preview 04:11

Reading contents of the HEAD file Preview 01:15

Git Crash Course Summary Preview 00:58