Prepare for commit

Git prepares for a commit before it commits. Use the " git add" command to prepare for commit.

# Put one file ready for commit
git add filename

Use "git add." To put all the files under the current directory in the commit ready state. Starting with Git 2.0, deleted files will also be ready for commit.

# Put files under the current directory ready for commit
git add.

Check the commit preparation status

Use the " git status" command to check the commit readiness.

# Check the commit preparation status
git status

Here is a sample output when ready to commit. "Templates / index.html" has been modified and "README.md" has been deleted, and it is ready for commit.

$git status
On branch master
Your branch is up to date with'origin / master'.

Changes to be committed:
  (use "git reset HEAD <file> ..." to unstage)

        deleted: README.md
        modified: templates / index.html

Check the difference between files to be committed

Before committing, let's check the difference between the files that are actually committed. Use the "--cached" option of the " git diff" command to see the differences between the files that are actually committed. Note that "git diff" without the "--cached" option will show the difference between the working directory and the commit-prepared files.

#Check the differences between the files to be committed
git diff --cached

This is an output example.

$git diff --cached
diff --git a /README.md b / README.md
deleted file mode 100644
index 372dc9d3..00000000
--- a / README.md
+++ / dev / null
@@-1,5 +0,0 @@
diff --git a /README.md b / README.md
deleted file mode 100644
index 372dc9d3..00000000
--- a / README.md
+++ / dev / null
@@-1,5 +0,0 @@
-<H1>
--Introduction to Perl Seminar
-</h1>
――――
――――
diff --git a / templates / index.html b / templates / index.html
index 66c755ea..f0b95399 100644
--- a / templates / index.html
+++ b / templates / index.html
@@-2,7 +2,7 @@

 An introductory course on <b> Perl text processing </b> and <b> regular expressions </b>. Perl is a programming language that excels at <b> text processing </b> and <b> regular expressions </b> in the fields of <b> Linux server management </b> and <b> Web system development </b>. Active in. Perl as the basis for text processing and regular expressions
Explains the logging language from the basics. You can also learn Linux and web development. Hello World!

-Perl is installed on most Linux / Unix and is backwards compatible and stable
It has a good reputation for being operational.
+ Perl is installed on most Linux / Unix and is backwards compatible and stable
It has a good reputation for being operational. How nice.

 <h3> Introduction to Perl Programming </h3>

Cancel commit preparation

Use the " git reset" command to cancel the commit preparation.

# Cancel commit preparation
git reset

If you make a mistake, never add the "--hard" option to the "git reset" command to cancel the commit preparation. All the changes in the working directory I've written so far will be canceled and tears will come out. If there are any changes left on the text editor, hurry up and overwrite them.

Associated Information