| by Arround The Web | No comments

How to Use “git status” for Inspecting Git Repository

Git users often create, add, modify, and delete source code files. Users are also allowed to check the time-by-time working area status, which is also known as inspecting the Git repository. For this corresponding purpose, the “git status” command is used. It displays the current working repository along with the local branch state. The “git status” command helps users to keep track of their changes and understand the overall status of the Git project.

In this guide, we will provide the usage of the “git status” command for inspecting the Git repository.

How to Use the “git status” Command for Inspecting Git Repository?

To utilize the “git status” command for inspecting the Git repository, try out the provided instructions:

Step 1: Go to Git Local Directory

Initially, navigate toward the local Git repository by using the “cd” command:

cd "C:\Users\user\Git\newRepo"

Step 2: View the Current Status

Check the current state of the Git local directory by executing the “git status” command:

git status

The given image indicates that the working area is clean and nothing to commit:

Step 3: Add Content

Utilize the “touch” command to generate new files in the Git working area:

touch textfile.txt file5.py file6.html

Step 4: Check Current Working State

Now, run the below-mentioned command to check whether the files exist in the working directory or not:

git status

The below-stated output shows that the generated files exist in the Git working directory as untracked:

Step 5: Track Changes

Now, let’s track a single file using the “git add” command by specifying the file name that needs to add in the staging area:

git add textfile.txt

Step 6: Verify Tracked File

To check the current status, run the “git status” command:

git status

The resultant image shows that the “textfile.txt” has been added to the staging area and is ready to commit. Furthermore, there are some untracked files also available in the Git working directory that need to be tracked:

Furthermore, multiple options/flags are available, along with the “git status” command for desired output. Some of them are listed below:

  • –porcelain” option is utilized for generating output that is script-parseable.
  • uno” is used to show only tracked files.
  • -v” option displays file names that have been changed and also shows the textual changes that are staged to be committed.
  • -long” option is used to show the output in a long format.
  • -s” flag is used to get the output in the short format.

For better understanding, try the above options and the “git status” command.

Examples 1

Execute the “git status –porcelain” command to show the Git status in scripting format:

git status --porcelain

In the below image “A” indicates that the file has been tracked, and “??” determines that these files are untracked:

Examples 2

The “git status -uno” command is used to show only tracked files and ignore the untracked file:

git status -uno

It can be noticed that the above command displayed the status of the tracked file:

That’s all about using the “git status” command for inspecting the repository.

Conclusion

To use “git status” for inspecting the Git repository, first, move to the Git local directory and view the current status. Then, generate files and check the current status of the Git working directory. Next, track the file and verify the tracked file by checking the status. This blog stated the usage of the “git status” command for inspecting the Git repository.

Share Button

Source: linuxhint.com

Leave a Reply