Git Basic and most useful commands

 

Git Configuration:

Configure the author name and email address to be used with your commits to telling Git who you are?

git config --global user.name "yourUserName"

git config --global user.email "email@domain.com"

Git initialization or Create a new local repository

git init

Clone out a remote repository

git clone your/repository/path

Add files in Git

Add one or more files to the staging

git add <filename>  // one file

git add *  // all file

Commit commands

Commit changes to head (but not yet to the remote repository)

git commit -m "Commit message"

Commit any files you've added with git add, and also commit any files you've changed since then

git commit -a

Push: Send changes to the remote branch from local

git push origin <branchname>

Manage Git Branches

Create a new branch and switch to it

git checkout -b <branchname>

Switch from one branch to another

git checkout <branchname>

List all the branches in your repo, and also tell you what branch you're currently in

git branch

Get Update from the remote repository in Git

Fetch and merge changes from the remote server to your working directory

git pull origin <branchname>

Status: List the files you've changed and those you still need to add or commit

git status