| by Arround The Web | No comments

How Can I See the Changes in a Git Commit?

Git is a popular version control platform widely used to manage and maintain the project source code. Git developers can work on Git local repositories and remote repositories. Local changes are stored on the local machine through Git commit command. However, only tracked files that exist in the staging environment are considered to commit for changes.

This platform also permits Git users to commit changes and maintain the history of commits in the log, which helps the user to see recent changes and revert changes.

This blog will demonstrate how to see the Git commit changes.

How Can I See the Git Commit Changes?

To see the Git commit changes, first, make a new commit using the “git commit -m” command. For this purpose, check out the given procedure.

Step 1: Launch Git Terminal

Firstly, launch the “Git bash” Git terminal from the Startup menu:

Step 2: Change the Git Local Repository

Next, utilize the “cd” command to change the Git local repository:

$ cd "C:\Git"

Step 3: Make a New File

Create a new file that will later be committed for modification:

$ touch NewFile.txt

Step 4: Add File to Staging Environment

Next, add the newly untracked file to the staging environment using the mentioned command:

$ git add NewFile.txt

Check the Git repository status to verify whether the file is added to the staging area or not:

$ git status

It can be observed that the file is added to the staging area and is ready to commit changes:

Step 5: Commit Changes

Next, commit the file from the staging area using the below-provided command. Here, the “-m” flag is used to embed the message along the commit:

$ git commit -m "New Changes Committed"

Step 6: See Changes in Git Commit

See the Git commit changes by checking the Git log. To do so, run the “git log” command:

$ git log

The below output shows the recent changes in a Git commit and verifies that the new commit is successfully done:

Alternatively, use the “git log –raw” command to see the details of the updates as well:

$ git log --raw

Here you go! You have learned how to see the changes in a Git commit.

Conclusion

To see changes in the Git commit, open the Git local repository. Next, create a new file and add it to a staging environment. After that, commit the staged file using the “$ git commit -m” command. Next, to see the Git commit changes, utilize the “$ git log” command. This post has taught you how to see changes in a Git commit.

Share Button

Source: linuxhint.com

Leave a Reply