git command cli code example

Example 1: git commands

git init
//add all
git add .

//cancel adds
git reset

//cancel commits
git reset HEAD^
//cancel last 3 commits
git reset HEAD~3

//when first commit
git push -u origin master

//remove remote origin
git remote remove origin

//reset remote origin
git remote add origin https://github.com/yourname/project.git

Example 2: git commands

// displays the staging area
git status

// create a new repository 
git init

// add stages
git add --a or
git add .

// commit
git commit -m "your message"

// know your commit 
git log

// skipping staging area Note: Untrack file will not skip
git command -a -m "your message"



// Config user name and email
git config --global user.name "UserName"
git config --global user.email "emailId"

// check user name and email
git config user.name
git config user.email