Git Staging Environment

Git Staging Environment

One of the main functions of Git is the concepts of the Staging Environment and then Commit.

While working on files adding, editing, and removing files functions are performed. When the work is finished, the files must be added to a Staging Environment.

Staged files are files that are ready to be committed to the repository on which the current work is going on.

Now, we’ll add the index.html to the Staging Environment:

[user @localhost] git add index.html

Let’s check the status of the file:

[user @localhost] git status

On branch master

No commits yet

Changes to be committed:

(use “git rm –cached …” to unstage)   

new file: index.html

The file has been added to the staging environment.

Git Add More than One File

More than one file can be staged at a time. Let’s add 2 more files to the working folder by using the text editor again.

A README.md file that describes the repository

Example:

# hello-world

Hello World repository for Git tutorial

This is an example repository for the Git tutorial on https://www.tutorial.com

A basic external style sheet (bluestyle.css):

body {

background-color: lightblue;

}

h1 {

color: navy;

margin-left: 20px;

}

And update index.html to include the stylesheet:

<!DOCTYPE html>

<html>

<head>

<title>Hello World!</title>

<link rel=”stylesheet” href=”bluestyle.css”>

</head>

<body>

<h1>Hello world!</h1>

<p>This is the first file in my new Git Repo.</p>

</body>

</html>

Now add all files in the current directory to the Staging Environment:

[user @localhost] git add –all

[user @localhost] git status

On branch master

No commits yet.

Changes to be committed:

(use “git rm –cached …” to unstage) new file: README.md new file: bluestyle.css new file: index.html