Home  >  Article  >  Development Tools  >  What are the statuses of git files?

What are the statuses of git files?

WBOY
WBOYOriginal
2022-06-30 17:47:505070browse

Git files have three states: 1. Submitted state (committed), indicating that the data has been safely saved in the local database; 2. Modified state (modified), indicating that the file has been modified but has not been saved. to the database; 3. Staged status, which means that the current version of a modified file has been marked so that it will be included in the next submitted snapshot.

What are the statuses of git files?

The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.

What are the statuses of git files?

There are three statuses of git files:

What are the statuses of git files?

For the three statuses of Git files, here You need to understand the three work areas of a Git project: workspace, staging area, and Git warehouse.

What are the statuses of git files?

Knowledge expansion:

The basic Git workflow is described as follows:

  • Modify something in the workspace some documents.

  • Take a snapshot of the modified file and then add it to the staging area.

  • Commit the update and permanently dump the file snapshot saved in the staging area to the Git repository.

GIt has three states before submission: Untracked files (not tracked and monitored), Changes not staged for commit, and Changes to be committed. These three states can be converted at will.

Untracked files: The marked files have not been monitored and managed by git. At this time, you can use the git add command to add files that are prompted as Untracked files to the git warehouse.

Changes to be committed: Files in this status have been snapshotted in the temporary storage area and are waiting to be committed. At this time, you can use git commit -m "comment" to submit the file.

At this time, you can also use the git rm --cached file name command to restore the file status to the Untracked status.

Files in the Changes to be committed state can be submitted or continue to be modified.

Changes not staged for commit: After the file in the Changes to be committed state is not committed and continues to be modified, check through git status and you will have the Changes not staged for commit state. This status indicates that the file has been modified, but has not been placed in the staging area and a snapshot has not been generated. Two operations can be performed at this time, commit and add operations.

If a commit operation is performed, only the files before modification will be submitted to the git version directory (only files in the temporary storage area and files with a status of Changes to be committed can be submitted); if necessary, the modification will be If the subsequent files are also submitted, you need to use the git add command to add the files to the staging area. If you want to undo changes, use: git checkout --filename.

Recommended study: "Git Tutorial"

The above is the detailed content of What are the statuses of git files?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn