The method of saving file or a collection of files is whole lot different process in git than in a file editor.In order to save the latest versions of git project we will use the following commands:
- git add
- git status
- git commit
git add is an informant command.It acts as an intermediate between the user and git. It informs the git that changes are to be included in the next stage.It does not affect the repository until and unless git commit command is called.
As the name suggest, this command displays the state of working area and staging area.It displays the paths in working directory and lists the files which are tracked or untracked. This command is very helpful as it let the user know what he is doing before actually committing changes that he does not want to.
This command captures the changes.This command along with git add is one of the mst frequently used command. Git commit and git add are the commands which go along with each other.
Following are some important options of git commit command:
It includes all currently changed files in this commit, but new untracked files are not affected.
- -m “message
This creates a commit command with a displayed message.This command by default opens a locally configured text editor.
- -am “message”
This is the shortcut command that combines -a and -m options.
This option enable the user the amend the last commit. If user do not specify commit message with -m he/she will be prompted with message of previous commit command by default. This commands does not create a new commit but ecits the last.
Below are the snapshots of how above commands works
*Creating a python file
*Using git add, git status, git commit commands in our first commit
*Changing or updating the Number.py file in IDLE and saving it
*Again using git add, git status, git commit commands in our Second commit
Git add and git commit commands are the core commands. git add is used to tell the changes that needs to be staged for the next commit command.Then git commit is used to snapshot the staged changes.Git status is used to provide the state of staging area.