Common Git Commands

Overview

Git is a modern Source Control Management tool. It’s wildly popular since it provides a mechanisms to broadly share and merge code bases.

This article lists the most common commands and by no means replaces the extensive documentation found here: git-scm.com/doc

Commands

Configure Git

git config –global user.name “wassamz”
git config –global user.email “wassam@email.com”

Set the remote repository origin

git remote add origin https://github.com/wassamz/gitfun

Clone repository

git clone URL

Add file to local staging

git add <filenames>

Status of file changes

git status

Check for file differences

git diff

Commit change to local repository

git commit -m “descriptive commit message”

Push change to repository

git push -u origin master
git push

List all branches

git branch

Switch to a different branch

git checkout banch-name

Merge branch

git merge <branch name>

Delete branch on remote repository

git push –delete origin <branch name>

Delete branch in local repository

git branch –delete <branch name>

[siteorigin_widget class=”WP_Widget_Media_Image”][/siteorigin_widget]