Git Commands

npm

Create a new git Repository

git init

Adding files to Staging Area

git add .

Commiting files

git commit -m 'message'

Check Status

git status

View Commits

git log

Switching to previous commit

git checkout 881d3dd7913f(Commit no)

Switching to previous commit by creating a new branch

git checkout -b $Branch_Name 881d3dd7913f(Commit no)

show all branches

git branch

Creating a new branch

git branch $Branch_name

Switching to a branch

git checkout $Branch_name

Create and Switch to a branch

git checkout -b $Branch_name

Delete a branch

git branch -d $Branch_name

Merging branch(run this command from merge receving branch)

git merge $Branch_name

Activity

git reflog

Adding a remote

git remote add origin https://github.com/user/repo.git

Renaming Remote

$ git remote rename current_name new_name

Verfify new remote

git remote -v

Push content to remote Repository

git push $remote_name $Branch_Name

e.g. git push origin master

push branch to remote

git push $remote_name $Branch_Name

Deleting a remote Branch

git push origin($remote_name) -d $Branch_Name

Fetching content from Remote Repository

git fetch $remote_name $Branch_Name

Check the remote and local branch is upto date or not

git checkout

Pull the content from Remote Repository

git pull $remote_name $Branch_Name

e.g. git pull origin master