Published March 06, 2018 by

Git – Commit Files and Log

Using git commit command we commit changes to a local git repository. The changes can be any new files added or any existing files content, etc...

Command Syntax

 $ git commit -m "information of commit"

Example


For example, you have a working project on your system and added any new files to your project or edited any existing files. Let’s commit the changes.

 $ git commit -m "Update of Files"

2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file1.jsp
create mode 100644 file2.html


We can also view the commit logs before pushing them to a remote repository using git log command.

 $ git log

commit 65868752465278656gdfgfh5656jhghhfgg75675 (HEAD -> master)
Author: Subhash
Date:   Wed Mar 6 06:01:06 2018 +0530
"Update of Files"

commit 5c78f3jgbgfh8965ggfhglf5679jnhghfg3455f0      
Author: Subhash
Date:   Wed Mar 6 06:30:06 2018 +0530
"Added some Files"

We can also find more details of the commit from commit id using git show command.

 $ git show 65868752465278656gdfgfh5656jhghhfgg75675


Previous: Add and Delete Files                                                Next: Push Code