Saving a file in Git

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:

  1. git add
  2. git status
  3. git commit

.

Git add
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.



Git status
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.

Git commit
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:

  • -a
  • 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.

  • –amend
  • 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

Summarizing
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.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.