Git diff
Thegit diff is an informative command that shows the differences between two commits. It is used to compare the changes made in one commit with the changes made in another commit. Git consider the changed versions of same file as two different files. Then it gives names to these two files and shows the differences between them.
How to Read the Diff Output
a/– the original file (before changes)b/– the updated file (after changes)---– marks the beginning of the original file+++– marks the beginning of the updated file@@– shows the line numbers and position of changes
Comparing Working Directory and Staging Area
Comparing Staging Area with Repository
Comparing Two Branches
Comparing Specific Commits:
Git Stash
Stash is a way to save your changes in a temporary location. It’s useful when switching branches without losing work. You can then come back to the file later and apply the changes.Naming the stash
You can also name the stash by using the following command:View the stash list
You can view the list of stashes by using the following command:Apply the Most Recent Stash
You can apply the stash by using the following command:Apply Specific Stash
You can apply the specific stash by using the following command:stash@{0} is the name of the stash. You can use the git stash list command to get the name of the stash.
Applying and Drop a Stash
You can apply and drop the stash by using the following command:Drop the stash
You can drop the stash by using the following command:Applying stash to a specific branch
You can apply the stash to a specific branch by using the following command:Clearing the stash
You can clear the stash by using the following command:Git Tags
Tags are a way to mark a specific point in your repository. They are useful when you want to remember a specific version of your code or when you want to refer to a specific commit. Tags are like sticky notes that you can attach to your commits.Creating a tag
You can create a tag using the following command:Create an annotated tag
You can create an annotated tag using the following command:List all tags
You can list all tags using the following command:Tagging a specific commit
You can tag a specific commit using the following command:Push tags to remote repository
You can push tags to a remote repository using the following command:Delete a tag
You can delete a tag using the following command:Delete tag on remote repository
You can delete a tag on a remote repository using the following command:Conclusion
In this section, we explored how to use Git’s diff, stash, and tags commands. Though not used as frequently as add, commit, or push, they are incredibly helpful in debugging, context switching, and release management. See you next tutorial.Next: Managing History
Learn about rebase and reflog

