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 4. Edit & Commit

Edit and Commit Overview (1)

Edit and Commit Overview (1)

Git's Edit and Commit Overview

As we already explained in Chapter 1, Git applies the three-stage architecture. This architecture allows you to carefully select files and directories to be recorded in the version history. On this page, we'll cover a typical workflow using the three-stage architecture.

Recap of the Git three-stage architecture

Before explaining the typical workflow case example, we'll recap the Git three-stage architecture.

Three-Stage Architecture
  • Working Tree (Working Directory) is used to edit your working files. The files and directories that you usually see in the project directory are the Working Tree.
  • Staging Area is a buffer area used to prepare your working files for commit. The command to bring the working files into the Staging Area is git add. You can double-check if the files you added to the Staging Area are ready for commit. If the files are ready, you can commit and save them under your Local Repository. The command to commit files is git commit.
  • Local Repository is a place where committed files are stored with their version histories. By running the git commit command, you can commit your files in the Staging Area to save a version under your Local Repository. At this stage, your files are still on your computer and not accessible to others.
Git Three-Stage Architecture

A typical workflow of editing and managing commits

To help you understand the three-stage architecture concept more clearly, we'll give you an example of the typical operation cycle – how we manage the three stages using Git commands.

  1. Edit code in your project Working Tree (e.g., start to create a new app). At this point, the status of the project files is unstaged (or untracked if you create a new file).
  2. Once the code is updated, bring the files to the Staging Area using the git add command.
  3. Check the status of the Working Tree and the Staging Area by running the git status command.
  4. To save a version of the code, commit the files and record the version in the Local Repository using the git commit command.
  5. To see the version history, run the git log command. You can see the commit history with the commit hash.
  6. Then, you can further edit the code to add another feature (under the Working Tree) and repeat the above cycle (2~5).
  7. To check the differences in code among the different stages and commits, run the git diff command.
  8. If you want to reverse your recent edits in the Working Tree and bring the latest saved version (latest commit) back to the Working Tree, you can run the git restore command.
  9. If you see errors in the files already in the Staging Area, you can clear the files in the Staging Area by running the git reset command.
  10. When you want to delete files or directories from the Working Tree or Staging Area, you can run the git rm command. After running the git rm command, you need to run the git commit command to reflect the deleted status in the commit histories.
  11. git reset is also useful when you want to change version history. By specifying a commit hash when you run the command, you can erase the commit history after the specified commit.

You can also learn this topic offline. Click AmazonKindle.

More Topics to Explore

Detail Page Templates in Django

Template for Detail Page

Modularizing Django Templates with {% include %}

Modularize Templates – {% include %} tag

Chapter 1. Docker Introduction

Chapter 1. Docker Introduction

What is Fast-Forward Merge in Git

Fast-Forward Merge

Django Quick Start Guide: App Development Steps

Chapter 2. Django Quick Start Guide

Detail Page Templates in Django

Template for Detail Page

Modularizing Django Templates with {% include %}

Modularize Templates – {% include %} tag

Chapter 1. Docker Introduction

Chapter 1. Docker Introduction

What is Fast-Forward Merge in Git

Fast-Forward Merge

Django Quick Start Guide: App Development Steps

Chapter 2. Django Quick Start Guide

Tags:

Commit

Local Repository

Working Tree

Staging Area

Three Stage Architecture

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