Menu

Log in

Sign up

From beginner to master of web design, coding, infrastructure operation, business development and marketing

  • COURSES
  • HTML & CSS Introduction
  • HTML & CSS Coding with AI
  • Linux Introduction
  • Docker Basics
  • Git & GitHub Introduction
  • JavaScript Coding with AI
  • Django Introduction
  • AWS Basics
  • Figma Introduction
  • SEO Tutorial for Beginners
  • SEO with AI
  • OTHERS
  • About
  • Terms of Service
  • Privacy Policy

© 2024 D-Libro. All Rights Reserved

Git & GitHub IntroductionChapter 3. Git & GitHub Project Setup

Project Initiator – Make the First Commit

Project Initiator – Make the First Commit

Making the First Commit in Your Git Project

Although we’ll provide more details about Git operations on the local computer in the next chapter, in this chapter, we’ll briefly explain the four key commands that will help launch a project and make the first commit.

  • git add: with this command, you can add files to the Staging Area, where you can prepare and check files to register in your Local Repository.
  • git commit: with this command, you can register files in your Local Repository. Once the files are registered by this command, you can retrieve the saved version of the set of files anytime.
  • git status: with this command, you can see the status of the Working Tree and the Staging Area. This status lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git.
  • git log: with this command, you can see commit histories in a Local Repository.

The following practice helps you understand the four key commands.

Practice

bloovee-round-icon.pngDeveloper A (Project Owner Role)

Objective:
Make the first commit

On the previous page, we already set up a Local Repository, however, nothing is recorded in the repository yet.

Here, we’ll make a record of the HTML file (git_practice.html) created in the previous practice. As we haven't edited the file yet, prepare a dummy code first. We'll also use this file in the following practice sections.

1. Prepare an HTML file for this practice

Select the git_practice.html file to open it VS Code text editor.

Make the First Commit with VS Code: UI example 1

Edit the HTML file like the following, and save the file. You can use shortcuts to save the file (⌘ + S for Mac, Ctrl + S for Windows).

git_practice.html
<!doctype html>
<html lang="en">
<head>
 <style>
 h1 {
  color: blue;
  font-size:80px
 }
 </style>
</head>
<body>
 <h1>Hello World!</h1>
</body>

2. Check how the file is tracked by the Git system

Although the file is saved under the git_practice directory. It is still NOT recorded under the Git repository yet. To check the status, you can run the git log command. Open the command line in VS Code and run the command.

Make the First Commit with VS Code: UI example 2
Command Line - INPUT
git log 

You can see the message explaining that nothing has been committed yet like the one below.

Command Line - RESPONSE
fatal: your current branch 'master' does not have any commits yet

Also, if you run the git status command, you can see that there are untracked files.

Command Line - INPUT
git status 
Command Line - RESPONSE
No commits yet
Untracked files:
  (use "git add ..." to include in what will be committed)
        git_practice.html
nothing added to commit but untracked files present (use "git add" to track)

This means the file exists in the Working Tree, however, it's not registered in the Local Repository or the Staging Area.

3. Register the file in the Staging Area

To register the file in the Local Repository, first run the git add command. Make sure you are in the git_practice directory in your command line, and use . (period) to add all the files under the current directory.

Command Line - INPUT
git add .

At this stage, the files are not registered in the Local Repository yet. Check how the file is tracked by the Git system by running the git status command.

Command Line - INPUT
git status
Command Line - RESPONSE
On branch master
No commits yet
Changes to be committed:
  (use "git rm --cached ..." to unstage)
        new file:   git_practice.html

4. Register the file in the Local Repository

Run the git commit -m “the first commit” command to register the files in the Local Repository. You can add comments to the commit using the -m option.

If you don’t put this option, a text editor is launched to add comments. In that case, you need to type your comments in the text editor and save it. After closing the editor, you can come back to the command line.

Command Line - INPUT
git commit -m "the first commit"
Command Line - RESPONSE
[master (root-commit) 651e510] the first commit
 1 file changed, 13 insertions(+)
 create mode 100644 git_practice.html

Run the git log command again to check the commit status. Now you can see that the HTML file is registered in the Local Repository.

Command Line - INPUT
git log
Command Line - RESPONSE
commit 651e510f668aa841a49793b4fa18d2de74c41f5c (HEAD ->master)
Author: bloovee <bloovee2021@gmail.com>
Date:   Sat Oct 28 11:03:27 2023 +0800

    the first commit

You can also learn this topic offline. Click AmazonKindle.

More Topics to Explore

Efficient Access Mode Management with chmod Command

chmod Command with Numbers

Filtering Lists in Django Views

Customizing Views (2) – Filter Lists

Integrating Django Template Language (DTL)

Django Template Language (DTL)

Differences Between Websites and Django Web Apps

Websites vs. Django Web Apps

Managing User, Group, and Permissions in Linux

Chapter 4. User, Group and Permission

Efficient Access Mode Management with chmod Command

chmod Command with Numbers

Filtering Lists in Django Views

Customizing Views (2) – Filter Lists

Integrating Django Template Language (DTL)

Django Template Language (DTL)

Differences Between Websites and Django Web Apps

Websites vs. Django Web Apps

Managing User, Group, and Permissions in Linux

Chapter 4. User, Group and Permission

Tags:

Commit

Git & GitHub Introduction
Course Content

Chapter 1. Git & GitHub Overview

What Is Git?

What Is Version Control?

How To Save Versions in Git?

Collaborating on Git & GitHub – Remote Repository

Collaborating on Git & Git Hub – Branch

Git & GitHub Basic Life Cycle

Chapter 2. Git & GitHub Initial Settings

Git & GitHub Initial Settings Overview

Key Tool Preparation (1) – Mac

Key Tool Preparation (2) – Windows

Key Tool Preparation (3) – Linux Remote Server

Git User Settings – git config

Create GitHub Account

GitHub Access Authentication Settings

Generating PAT (Personal Access Token)

GitHub SSH Setup

Chapter 3. Git & GitHub Project Setup

Three Cases in Git & GitHub Project Setup

Git & GitHub Project Setup Overview in Different Cases

Building Remote Collaboration Practice Environment

Project Initiator – Key Steps To Launch Git Project

Project Initiator – Create Local Repository (git init)

Project Initiator – Make the First Commit

Project Initiator – .gitignore File

Project Initiator – Create Remote Repository

Project Initiator – Link Between Remote and Local Repositories (git remote add)

Project Initiator – Upload Local Repository to Remote Repository (git push)

Project Initiator – Grant Remote Repository Access to Project Members

Project Member – Start Project As Collaborator

Project Member – Create Copy of Project Code on Local Computer (git clone)

Non-Member – Start Project With Replica of Existing Repository (Fork)

Fork vs. Clone

Chapter 4. Edit & Commit

Git Regular Workflow – Edit & Commit

Edit and Commit Overview (1)

Add Files to Staging Area – git add

Commit Files – git commit

HEAD and INDEX

Check Status of Working Tree and Staging Area – git status

Check Commit Histories – git log

Check Differences – git diff

Restore Files to Working Tree – git restore

Undo Changes – git reset

Delete Files – git rm

Edit and Commit Overview (2)

Chapter 5. Work With Branches

Git Regular Workflow – Work With Branches

What Is Branch?

Branch Operation Basic Life Cycle

Create Branch and Check Branch Status – Git Branch

Switch Current Branch (1) – Git Checkout

Switch Current Branch (2) – Git Switch

Merge Branches – Git Merge

Fast-Forward Merge

Non-Fast-Forward Merge (No Option)

Non-Fast-Forward Merge (--no-ff Option)

Squash Merge

Rebase Branch – Git Rebase

Managing Conflict

Stash Changes – Git Stash

Chapter 6. Remote Collaboration

Git Regular Workflow – Remote Collaboration

Remote Collaboration Overview

Link With Remote Repository – Git Remote

Upload to Remote Repository – Git Push

Download Remote Repository and Merge to Local Repository – Git Pull

Get Remote Repository Information to Local Repository – Git Fetch

Pull vs. Fetch

Request for Review and Merge – Pull Request

Merge Operation Using GitHub

Chapter 7. Supplemental Topics

Git Key Commands and GitHub Key Features

Git & GitHub Glossary

GitHub Other Features

Chapter 1. Git & GitHub Overview

What Is Git?

What Is Version Control?

How To Save Versions in Git?

Collaborating on Git & GitHub – Remote Repository

Collaborating on Git & Git Hub – Branch

Git & GitHub Basic Life Cycle

Chapter 2. Git & GitHub Initial Settings

Git & GitHub Initial Settings Overview

Key Tool Preparation (1) – Mac

Key Tool Preparation (2) – Windows

Key Tool Preparation (3) – Linux Remote Server

Git User Settings – git config

Create GitHub Account

GitHub Access Authentication Settings

Generating PAT (Personal Access Token)

GitHub SSH Setup

Chapter 3. Git & GitHub Project Setup

Three Cases in Git & GitHub Project Setup

Git & GitHub Project Setup Overview in Different Cases

Building Remote Collaboration Practice Environment

Project Initiator – Key Steps To Launch Git Project

Project Initiator – Create Local Repository (git init)

Project Initiator – Make the First Commit

Project Initiator – .gitignore File

Project Initiator – Create Remote Repository

Project Initiator – Link Between Remote and Local Repositories (git remote add)

Project Initiator – Upload Local Repository to Remote Repository (git push)

Project Initiator – Grant Remote Repository Access to Project Members

Project Member – Start Project As Collaborator

Project Member – Create Copy of Project Code on Local Computer (git clone)

Non-Member – Start Project With Replica of Existing Repository (Fork)

Fork vs. Clone

Chapter 4. Edit & Commit

Git Regular Workflow – Edit & Commit

Edit and Commit Overview (1)

Add Files to Staging Area – git add

Commit Files – git commit

HEAD and INDEX

Check Status of Working Tree and Staging Area – git status

Check Commit Histories – git log

Check Differences – git diff

Restore Files to Working Tree – git restore

Undo Changes – git reset

Delete Files – git rm

Edit and Commit Overview (2)

Chapter 5. Work With Branches

Git Regular Workflow – Work With Branches

What Is Branch?

Branch Operation Basic Life Cycle

Create Branch and Check Branch Status – Git Branch

Switch Current Branch (1) – Git Checkout

Switch Current Branch (2) – Git Switch

Merge Branches – Git Merge

Fast-Forward Merge

Non-Fast-Forward Merge (No Option)

Non-Fast-Forward Merge (--no-ff Option)

Squash Merge

Rebase Branch – Git Rebase

Managing Conflict

Stash Changes – Git Stash

Chapter 6. Remote Collaboration

Git Regular Workflow – Remote Collaboration

Remote Collaboration Overview

Link With Remote Repository – Git Remote

Upload to Remote Repository – Git Push

Download Remote Repository and Merge to Local Repository – Git Pull

Get Remote Repository Information to Local Repository – Git Fetch

Pull vs. Fetch

Request for Review and Merge – Pull Request

Merge Operation Using GitHub

Chapter 7. Supplemental Topics

Git Key Commands and GitHub Key Features

Git & GitHub Glossary

GitHub Other Features