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
Java Parse JSON String To Object Miscellaneous 24-03-2023
Java Program For Date And Time Miscellaneous 24-03-2023
Java Binary Search Tree Implementation Miscellaneous 21-03-2023
Java Program To Merge Two PDF Files Miscellaneous 18-03-2023
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

1