Commit in Git

Jerry commits (deposits) the changes and he wants to correct them for his recent commits. In this case, the function git commit -a will help do this. This function changes the last commit including your commit message; It creates a new commit ID.

Before custom operation, he checks the commit log.

 [jerry @ CentOS project] $ git log 

The above command will produce the following result:

 commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 
Author: Jerry Mouse
Date: Wed Sep 11 08:05:26 2013 +0530

Implemented my_strlen function


commit 19ae20683fc460db7d127cf201a1429523b0e319
Author: Tom Cat
Date: Wed Sep 11 07:32:56 2013 +0530

Initial commit

Jerry commits new changes to the --a function, and observes the commit log.

 [jerry @ CentOS project] $ git status -s 
M string.c
?? string

[jerry @ CentOS project] $ git add string.c

[jerry @ CentOS project] $ git status -s
M string.c
?? string

[jerry @ CentOS project] $ git commit --a -m 'Changed return type of my_strlen to size_t'
[master d1e19d3] Changed return type of my_strlen to size_t
1 files changed, 24 insertions (+), 0 deletions (-)
create mode 100644 string.c

Now git log will show a new commit message with the new commit ID:

 [jerry @ CentOS project] $ git log 

The above command will produce the following result:

 commit d1e19d316224cddc437e3ed34ec3c931ad803958 
Author: Jerry Mouse
Date: Wed Sep 11 08:05:26 2013 +0530

Changed return type of my_strlen to size_t


commit 19ae20683fc460db7d127cf201a1429523b0e319
Author: Tom Cat
Date: Wed Sep 11 07:32:56 2013 +0530

Initial commit

According to Tutorialspoint

Previous article: Review changes in Git

Next lesson: Push operation in HTML

4 ★ | 1 Vote

May be interested

  • Push operation in HTMLPhoto of Push operation in HTML
    jerry modifies the previous commits using the git commit -a operation (signing changes) and he is ready to push the changes. push operation saves permanent data to git repository. after a successful push operation, other programmers can observe jerry's changes.
  • Update activity in GitPhoto of Update activity in Git
    tom performs the simulation operation and sees a new file string.c. he wants to know who added this file to the repository and for what purpose, so he runs the git log command.
  • Stash operation in GitPhoto of Stash operation in Git
    suppose you are implementing a new feature of your product. your code is in progress, suddenly a visitor. because of this, you have to go out for a few hours. you cannot commit this code and cannot throw it away at your changes. so you need some temporary space, where you can keep these local changes and then return to commit it.
  • Online Repository in GitPhoto of Online Repository in Git
    github is a social network for programmers for software development projects using git revision management system. it also has a standard gui application for direct download (windows, mac, gnu / linux) to your computer from web sites. but in this tutorial, we only consider the cli section.
  • Operating Rename in GitPhoto of Operating Rename in Git
    so far, both tom and jerry are using manual commands to compile their projects. now, jerry decided to create a makefile for the project and also put a name for the file string.c.
  • Delete operation in GitPhoto of Delete operation in Git
    tom updates the local repository and finds the compiled binary in the src directory. after observing the commit message, he realizes that this code is added by jerry.