Basic Git Commands Guide

Basic Git Commands

git init - Repository Initialization

Creates a new Git repository.

Option Description
--bare Creates a bare repository without a working directory
--template=<template-directory> Uses templates from the specified template directory

Examples:

git init - Creates a new Git repository in the current directory
git init my_project - Creates a new Git repository in the specified directory
git init --bare remote_repo.git - Creates a bare repository (for server use)

git clone - Repository Cloning

Copies an existing repository to your local machine.

Option Description
--branch, -b <branch-name> Checks out the specified branch
--depth <depth> Creates a shallow clone with the specified depth
--recursive Recursively clones submodules

Examples:

git clone https://github.com/username/repository.git - Clones a remote repository
git clone https://github.com/username/repository.git my_folder - Clones to a specified folder
git clone --branch develop https://github.com/username/repository.git - Clones a specific branch
git clone --depth 1 https://github.com/username/repository.git - Clones only the latest commit (no history)