git status command is used within a Git repository to its current status including the current commit, any modified files, and any new files not being tracked by Git.
The output of
git status can vary widely, and it often includes helpful messages to direct the user to manage their repository. For example,
git status will show the user the files they would commit by running
git commit and the files they could commit by running
git add before running
git init command creates or initializes a new Git project, or repository. It creates a .git folder with all the tools and data necessary to maintain versions. This command only needs to be used once per project to complete the initial setup. For instance, the code block sets up the home folder as a new git repository.
$ cd /home$ git init
git diff filename command will display the differences between the working directory and the staging area in one specific file. Use
git diff filename before adding new content to ensure that you are making the changes you expect.
$ git diff hello.txtdiff --git a/hello.txt b/hello.txtindex 557db03..980a0d5 100644--- a/hello.txt+++ b/hello.txt@@ -1 +1 @@-Hello World+Hello World!
In Git, the
git log command shows all of the commit logs for a project. The following is displayed for each commit:
This command is particularly useful when you need to refer back to an old version of your project. The unique SHA code allows you to identify a point in your program’s history that you would like to revert to.
$ git logcommit 9d63f80111447544c303e9f1776fa08593a87310Author: codecademy <[email protected]ademy.com>Date: Wed Jan 13 18:55:53 2021 +0000Added updates to the filecommit 3ba6efbeece6ed530d85de5e313e52123fdf8cb4Author: codecademy <[email protected]>Date: Wed Jan 6 10:11:13 2021 -0400Completed first line of dialogue
git commit -m "log message here" command creates a new commit containing:
A commit is the last step in our Git workflow. A commit permanently stores changes from the staging area inside the repository. This command is almost always used in conjunction with the
git add command as
git add is used to add files to the staging area.
$ git commit -m "Added About section to README"[master 9d63f80] Added About section to README1 file changed, 10 insertions(+), 1 deletion(-)
Git is a command line software that keeps track of changes made to a project over time. Git works by recording the changes made to a project, storing those changes, then allowing a programmer to reference them as needed.
All Git commands follow the pattern
git <action> and, in order to use Git for a project, a project must first be initialized using the
git init command in the project’s root directory.
git add filename command is used to add the
filename file to the staging area. After your changes have been staged, you can use the
git commit command to permanently store your changes.
A Git project has three parts:
The Git workflow consists of editing files in the working directory, adding files to the staging area, and saving changes to a Git repository.