How To Create A Git Repository | Git repository commands

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

Program:

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


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


git config --global user.email "[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 ............... */
        

Notes:

  • First step for git configuration is to install git in you operating system. For that you can use the link https://git-scm.com/downloads
  • After installation you have to configure the user using the command (git config --global user.name "John" ). This command will configure the name of user and also you can configure the email of user using command - git config --global user.email "[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.

Tags

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

Similar Programs Chapter Last Updated
Find Unique Elements In List Java Miscellaneous 07-10-2023
Java Program To Implement A Custom equals() and hashcode() In Java Miscellaneous 07-10-2023
Java Program To Find The Intersection Of Two HashSets Miscellaneous 07-10-2023
Java Program To Remove Duplicate Elements From List Miscellaneous 07-10-2023
Java program to parse a date and time string from a log file and store it in a database Miscellaneous 19-09-2023
Java Program To Print All The Dates In A Month That Fall On A Weekend Miscellaneous 19-09-2023
Java Program To Find Number Of Working Days In A Month Miscellaneous 19-09-2023
Java Program To Calculate Age From Year Of Birth Miscellaneous 16-09-2023
How To Check If Two Strings Are Anagrams In Java Miscellaneous 22-08-2023
Java Program To Make A Snake Game Miscellaneous 15-08-2023
Java Program To Find Repeated Characters Of String Miscellaneous 15-08-2023
String To Array In Java Miscellaneous 11-08-2023
Java Program To Convert Date To String Miscellaneous 11-08-2023
Java Program To Convert String To Date Object Miscellaneous 11-08-2023
Java Program To Find Number Of Days In A Month Miscellaneous 11-08-2023
Java Program To Print First And Last Day Of Month Miscellaneous 11-08-2023
Java Program To Find Leap Year Between Two Dates Miscellaneous 11-08-2023
Java Code To Find Difference Between Two Dates In Years Months And Days Miscellaneous 11-08-2023
Java program to calculate age from year of birth Miscellaneous 29-06-2023
Swap Two Numbers Without Using Third Variable In Java Miscellaneous 02-06-2023
Java Program To Find The Average Of An Array Of Numbers Miscellaneous 02-06-2023
How Do You Find The Factorial Of A Number In Java Miscellaneous 02-06-2023
Java Program That Takes Two Numbers As Input And Prints Their Sum Miscellaneous 27-05-2023
How To Get The Length Of An Array In Java Miscellaneous 27-05-2023
Java Add Element To List Example Miscellaneous 19-05-2023
Java Program To Square All Items In List Miscellaneous 17-05-2023
Java Program To Merge Two Lists Miscellaneous 17-05-2023
How To Reverse A List In Java Miscellaneous 17-05-2023
Java Program To Find Unique Elements In An Array Miscellaneous 14-05-2023
Java Program To List All Elements In List Miscellaneous 30-04-2023

1 2