The classic expression of "saving" is similar to the Git term "committing". Git committing is an operation that saves a set of files, directories and their changes to the repository. Git commits can be created locally, then pushed to a remote server as needed with the help of the git push command. While saving changes in Git, you will have to deal with various commands, that are described below.

Introduction

git add

The git add is a command, which adds changes in the working directory to the staging area.With the help of this command, you tell Git that you want to add updates to a certain file in the next commit. But in order to record changes, you need to run git commit too.

git commit

The git commit command saves all currently staged changes of the project. Commits are created to capture the current state of a project. Committed snapshots are considered safe versions of a project because Git asks before changing them. Before running git commit command, git add command is used to promote changes to the project that will be then stored in a commit.

git diff

The git diff is a multi-function Git command, which is used to compare changes committed in Git. Particularly, with the help of this command you can take two input data sets and output the modifications between them.

git stash

The git stash command shelves changes you have made to your working copy so you can do another work, and then come back and re-apply them.

.gitignore

Git ignore files are located in a file called .gitignore. They are edited and committed by hand, as a git ignore command doesn’t exist. Git ignore files contain patterns matched against file names, with the help of which you decide to ignore or not each file.

Practice Your Knowledge

What are the functions of various Git commands related to saving changes?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?