Most Important & Commonly Used GIT Commands: Part 1

Git is a free and open source distributed Version Control System (VCS) that's responsible for everything GitHub related that happens locally on your computer. This post features the most important and commonly used GIT commands for easy reference.

Installation and GUI's

Windows: https://windows.github.com

Mac: https://mac.github.com


SETUP

Configure user information used across all local repositories.

set a name that is identifiable for credit when review version history.
git config --global user.name "[firstname lastname]"

set an email address that will be associated with each history maker.
git config --global user.email "[email]"

set automatic command line coloring for git for easy reviewing.

git config --global color.ui auto

INITIALIZATION

Configuring user information, initializing and cloning repositories.

initialize an existing directory as a GIT repository.
git init

retrieve an entire repository from a hosted location via URL.

git clone [url]

STAGE & SNAPSHOT

Working with snapshots and the GIT staging area.

show modified files in working directory, staged for your next commit.
git status

add a file as it looks now to your next commit (stage).
git add [file]

un-stage a file while retaining the changes in working directory.
git reset [file]

diff of what is changed but not staged.
git diff

diff of what is staged but not yet committed.
git diff --staged

commit your staged content as a new commit snapshot.

git commit -m "[message]"

BRANCH & MERGE

Isolating work in branches, changing context and integrating changes.

list your branches, a * will appear next to the currently active branch.
git branch

create a new branch at the current commit.
git branch [branch-name]

switch to another branch and check it out into your working directory.
git checkout

merge the specified branch's history into the current one.
git merge [branch]

show all commits in the current branch's history.
git log

That's it for part 1. To see the part 2 of the most important and commonly used GIT commands, click here.

Post a Comment

0 Comments