Save Changes
Understand how to save changes in Git.
Please follow the sequence.
Clone the repository KarChunT/git-training to work-on.
git add
The git add
command simply pushes files or directories to staging area/environment. By doing this, you tell Git to include those changes in the next commit. Of course, you can add more than one file/directory at a time.
git status
The git status
command simply lists which files are staged, unstaged, and untracked.
git commit
The git commit
command simply saves or commits that file changes into a Git project. You can think of as snapshots or milestones along the timeline of a Git project.
git log
The git log
command shows the information that you need to know about all the commits, such as
- commit hash
- author name
- data of the commit: which files to be committed
- commit message
git diff
The git diff
command shows the differences between two data sources. Data sources can be
- commits
- branches
- files, etc
How to read this?
In this example, 8 lines have been extracted starting from line number 50. Then, 12 lines have been added starting at line number 50.
git restore
The git restore
command will discard changes in working directory or if a file is tracked then you can restore or unstage that file to match the version in HEAD.
.gitignore
.gitignore
is a file that will include all the globbing patterns to ignore the file to be commited. These could be the files like
- build artifacts like
/bin
,/target
- machine generated files like
.pyc
- dependency caches like
node_modules
- log file
- environments or secrets like
.env