Git commands

Create new local repo
# git init

Clone existing repo on local machine
# git clone <REPO-URL>

Clone specific branch
#git clone -b <branch-name> <REPO-URL> <FOLDER_NAME>/

Check file status
# git status

Check current branch name
# git branch

Check all branches
# git branch –av

Create new branch
# git branch <branch-name>

Delete a local branch
# git branch –d <branch-name>

Create & navigate to new branch
# git checkout -b <branch-name>

Add all changes/files to commit
# git add.

Add some changes/file to commit
# git add -p <file>

Commit all local changes
# git commit –m “<your comment>”

Push to repo
# git push origin <branch-name>

Check all configured remotes
# git remote –v

Check info about any remote repo
# git remote show <remote-repo>

Download latest changes
# git pull <remote-repo> <branch-name>

Push/upload local changes to remote repo
# git push <remote-repo> <branch-name>

Check all commits history
# git log

Check log for any file
# git log –p <file>

Merge branch
# git merge <branch-name>

Revert a commit
# git revert <commit>