DevOps
Version Control
GIT
GIT Commands

GIT Commands

Basic Commands

CommandDescription
git initInitializes a new Git repository in the current directory
git clone <repository-url>Clones an existing Git repository.
git statusShows the current status of the repository.
git add <file-name>Stages changes for a commit.
git add .Stages all changes for a commit.
git restore --staged <file>Unstages changes.
git reset HEAD .Unstages all changes.
git restore <file>Discards changes in the working directory.
git diff --stagedShows the changes that have been staged.
git diffShows the changes that have not been staged.
git commit -m "message"Commits staged changes with a message.
git logShows the commit history.
git log --onelineShows a summarized version of the commit history.

Remote Commands

CommandDescription
git remoteLists the remotes for the current repository.
git remote add <name> <url>Adds a new remote to the current repository.
git pull <remote> <branch>Pulls changes from a remote repository.
git push <remote> <branch>Pushes changes to a remote repository.

Branching Commands

CommandDescription
git branchLists all the branches in the repository.
git branch <branch-name>Creates a new branch.
git checkout <branch-name>Switches to a different branch.
git checkout -b <branch-name>Creates and switches to a new branch.
git merge <branch-name>Merges changes from one branch into another.