How To Create A Git Repository | Git repository commands

Chapter: Miscellaneous Last Updated: 31-07-2021 10:46:51 UTC


            /* ............... START ............... */

git config --global "John"    /* User name configuration command  */

git config --global "[email protected]"  /* User email configuration command */

git init    /* this command will create a git repository */

/* Output
Initialized empty Git repository in /home/john/GitTest/Java/.git/

git add WhatIsGIT.SQL     /* A file with name WhatIsGIT.SQL  created and adding to repository */

git status    /* Git Status command will give the status of the current repository */

/* Output
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

	new file:   WhatIsGIT.SQL


git commit -m "First commit"  /*  This command will commit the file to repository , after -m you can give any message for the commit */

[master (root-commit) 2edb0bf] First commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 WhatIsGIT.SQL

git log     /* Git log command will give the logs of changes made in git using commit command * /

/* Output 
commit 2edb0bfc1fda92932cdbf3ae6c998afaa38d7db4 (HEAD -> master)
Author: John <[email protected]>
Date:   Sat Jul 31 14:04:07 2021 +0400

    First commit
                /* ............... END ............... */


  • First step for git configuration is to install git in you operating system. For that you can use the link
  • After installation you have to configure the user using the command (git config --global "John" ). This command will configure the name of user and also you can configure the email of user using command - git config --global "[email protected]"
  • After configuring the user name and mail you can create a git repository using the command - git init
  • Next step is to create a file in repository. In this example I have create a file WhatIsGIT.SQL.
  • git add WhatIsGIT.SQL command will add the file to the repository.
  • git status will displays the state of the working directory and the staging area.
  • git commit command will commit the file to repository, you can give a message during the commit like "-m "Any comment" "
  • git log command will give the details of changes in repository. You can revert the changes using the checkout command.
  • Common Git Commands are git init, git add, git commit, git status, git config, git branch, git checkout, git merge.
  • Please refer the program section for more clarity.


What is a Git repository, How to Create a New Repository in Git, Git repository commands with Example

Similar Programs Chapter Last Updated
Currency Formatter In Java | How To Format Currency In Java Miscellaneous 19-07-2021
Factory Design Pattern In Java Miscellaneous 11-05-2021
Data Types In Java Miscellaneous 09-06-2018
Java Program To Find Largest Element Of Array Miscellaneous 21-09-2017
Java Program To Check Whether Number Is Prime Or Not Miscellaneous 08-09-2017
Java Program To Find Power Of Number Using For Loop Miscellaneous 29-08-2017
Java Program To Find LCM Of Two Numbers Miscellaneous 29-08-2017
Java Program To Find GCD Of Two Numbers Miscellaneous 29-08-2017
Java Program To Check Whether An Alphabet Is Vowel Or Consonant Miscellaneous 25-08-2017
Java Program To Find ASCII Value Of Character Miscellaneous 25-08-2017
Java Object HashCode Method Miscellaneous 02-08-2017
Java Builder Design Pattern Example Miscellaneous 06-06-2017
Java Factory Design Pattern Example Miscellaneous 06-06-2017
Java Program To Print ASCII Values Miscellaneous 06-04-2017
Java Program To Find HCF LCM Of Two Numbers Miscellaneous 22-09-2018
Java String Array Iteration Miscellaneous 31-03-2017
Java Array Size Miscellaneous 30-03-2017
Java Integer toString Miscellaneous 30-03-2017
Java Sort Array Using Arrays.sort() Miscellaneous 28-03-2017
Java Print Array Using Arrays.toString Miscellaneous 28-03-2017
Java Nested Interface Miscellaneous 25-03-2017
Java Static Nested Class Miscellaneous 25-03-2017
Packages In Java Miscellaneous 24-03-2017
Java Strictfp Keyword Miscellaneous 24-03-2017
Java Call By Reference Miscellaneous 23-03-2017
Java Call By Value Miscellaneous 23-03-2017
Java Unboxing Example Miscellaneous 23-03-2017
Java Autoboxing Example Miscellaneous 23-03-2017
Java Format Currency Miscellaneous 15-02-2017
Java String To BigDecimal Conversion Miscellaneous 15-02-2017

1 2 3 4 5