Home > Development Tools > git > How to use GIT to view changed files

How to use GIT to view changed files

PHPz
Release: 2023-04-03 09:51:26
Original
8389 people have browsed it

GIT is a very powerful version control tool. It has rich functions and commands that can help developers work better together. In daily development, we may need to view the change files submitted to the warehouse and the current changes. So, this article will introduce how to use GIT to view changed files.

1. View the changed files submitted to the warehouse

After we submit the changes to the warehouse, we may not know which files were specifically modified by this change, so how do we view these changed files? ? The git diff command provides this functionality. Execute the following command to view the changed files submitted to the warehouse:

git diff <commit id> <commit id>
Copy after login

where <commit id> refers to the ID of the submission record.

Example:

git diff c5a82a5 54d9b41
Copy after login

After executing the above command, the terminal will display all changed files currently submitted to the warehouse and the specific changes.

2. Check the current changes

During the development process, we may need to check the currently modified files and the specific changes so that we can better carry out development work. So, how do you see the changes you've made so far? To view the current changes, we can use the following command:

git status
Copy after login

After executing the above command, the terminal will indicate the currently modified files and their status. If the file has been modified but not submitted, the following information will be output:

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

   modified:   <file1>
   modified:   <file2>
Copy after login

As you can see, the file status is "modified". After the file name, GIT will also tell you which branches your changes have been added to since the last commit.

3. View the modification history of a file

During the development process, we may need to view the modification history of a file so that we can better understand the changes to the file. Then, we can use the following command to view the modification history of a file:

git log <file>
Copy after login

After executing the above command, the terminal will output all modification history of the file, including submission record, author, submission time and other information.

4. View the changes in a specified submission

Sometimes, we may need to view the specific changes in a submission so that we can better understand the development process. Then, we can use the following command to view the specific changes of a commit:

git show <commit id> <file>
Copy after login

Example:

git show 54d9b41 file1.txt
Copy after login

After executing the above command, the terminal will output all changes of the specified commit.

Summary

Through the introduction of this article, we can know how to use GIT to view changed files. GIT provides a wealth of commands and functions to help developers better perform version control and collaborative work. Therefore, mastering the basic usage of GIT is very helpful for our development work.

The above is the detailed content of How to use GIT to view changed files. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template