Skip to content

Latest commit

 

History

History
57 lines (47 loc) · 2.73 KB

Git_commands.md

File metadata and controls

57 lines (47 loc) · 2.73 KB

Git Commands Cheat Sheet

Git Installation

Install Git on Ubuntu:

sudo apt-get update
sudo apt-get install git

Install Git on CentOS

sudo yum update
sudo yum install git

Verify Git installation:

git --version

Basic Git Commands

git init : Initialize a new Git repository.
git clone : Clone a repository into a new directory.
git status : Show the working tree status.
git add : Add file(s) to the staging area.
git commit -m "message" : Commit changes with a message.
git push : Push local changes to a remote repository.
git pull : Fetch from and integrate with another repository or a local branch.
git branch : List, create, or delete branches.
git checkout : Switch branches or restore working tree files.
git merge : Merge changes from a specified branch into the current branch.
git fetch: Download objects and refs from another repository.

Repository Management

git remote add origin : Add a remote repository.
git remote -v: List all remote repositories.
git remote show origin : Show information about a remote repository.
git remote rename : Rename a remote.
git remote remove : Remove a remote repository.
git tag: Create, list, delete or verify a tag object.

Undoing Changes

git reset : Unstage file(s) from the staging area.
git checkout -- : Discard changes in working directory.
git revert : Revert a commit.
git reset --hard : Reset to a previous commit and discard changes.
git clean -f: Remove untracked files from the working directory.

Branching and Merging

git branch: List, create, or delete branches.
git checkout : Switch branches or restore working tree files.
git merge : Merge changes from a specified branch into the current branch.
git rebase : Reapply commits on top of another base tip.
git cherry-pick : Apply changes from a specific commit.