How to skip git add?

Do you think it’s extremely troublesome to use git add every time before we want to make a commit? Let’s try git commit -am

Hello everyone. It’s Ray!

Today I am going to share how to simplify git add and git commit, let’s welcome git commit -am

As shared previously, every time before making a commit, we need to use git add to update the progress to be committed, and then leave the specific message for this commit before completing this commit.

Some think it’s a good design, after all, it’s best to err on the side of caution. However, some don’t, thinking that it’s a bit troublesome.

No matter which one you are belong to. today I’m going to share with you how to combine and turn them into one move.

Firstly, let’s add a new code in example1.html file as follows:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>First example</title>
</head>
<body>
<p>This is the first example</p>
<p>We add a new paragraph on the first example</p>
<p>This is the example commit for git commit -am</p>
</body>
</html>

enter git status

As image below, the example1.html has been modified, and it requires git add to update what will be committed before a commit.

According to articles that I posted previously, we need to git add, and then git commit, and finally leave the specific message before a completed commit.

Now let’s try something simpler.

Enter Git commit -am "example for git commit -am"

Enter git status to check the condition.

enter git log

As image below, we’ve successfully committed.


Here I’m going to further explain how git add works.

When we create a new file, we need to add this file into the list of tracked files, and to do so, we use git add

When one of the tracked file is modified, and we would like to make a commit, we would need to update what will be committed, and we also use git add to do so.

That said, git commit -am would not work on a newly added file which hasn’t been added into tracked file list.

Caution! -a here means automatic, which would automatically add ALL those modified file from tracked file list.

After reading through this article, are you more familiar with Git?

See you guys!

What is in git log? How to use checkout

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×