Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does git add mean?

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what git add means, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

"git add" means "tracking new files", or adding content from the working directory to the staging area; the "git add" command can track not only a single file, but also an entire directory, or even multiple directories and files at the same time.

The operating environment of this tutorial: Windows7 system, Git2.30.0 version, Dell G3 computer.

What exactly does git add mean? In official terms: track new files, or add content from the working directory to the staging area.

The function of git add is to add the code we need to commit from the workspace to the staging area, which is to tell the git system which files we want to submit, and then we can use the git commit command to submit.

To explain it with a case in life is:

Git add is like going to the supermarket, loading a cart of goods (similar to revised documents) in a shopping cart, and then going to the cashier to check out. As you choose more items at one time, you may have to hesitate to buy them all. At this time, you can take the goods one by one to the cashier to scan the code and settle the bill (similar to git add fileA, git add fileB … , that is, add and specify some files), or buy them all with deep pockets (similar to git add. /, that is, add all files), and then pay the bill and take it home (git commit and git push).

Track a single file "git add..."

$git add yourFileName

If you create a file named "newFile.md", when you check the status through the git status command, it should look like this:

$git status # View the file status of the current directory On branch master Your branch is up-to-date with 'origin/master'. # origin/master means "remote master branch" Untracked files: # list of untracked files (use "git add..." To include in what will be committed) # you can use "git add..." Command to track the file in order to submit the newFile.md # here is usually the "red" nothing added to commit but untracked files present (use "git add" to track)

Execute "git add..." After that:

$git add newFile.md # track the newFile.md file $git status # View the file status of the current directory On branch masterYour branch is up-to-date with 'origin/master'.Changes to be committed: (use "git reset HEAD..." To unstage) # you can use "git reset HEAD..." Command to discard the tracking file, that is, untrace new file: newFile.md # here is usually "green"

Track multiple files (folders) "git add. /"

$git add. / # in real development, this way of tracking files is the most commonly used

The git add command can track not only a single file, but also an entire directory (for example, the src directory command git add. / src), or even multiple directories and files at the same time (such as tracking all files in the current directory, folder command git add. /).

Thank you for reading this article carefully. I hope the article "what does git add mean" shared by the editor will be helpful to everyone? at the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report