Tag: Git

Learning Git

Git is a software that allows you to keep track of changes made to a project over time. Git works by recording the changes you made to a project, storing those changes, then allowing you to reference them as needed.

  1. A Working Directory where you’ll be doing all the work creating, editing, deleting and organizing files.
  2. A Staging Area where you’ll list changes you make to the working directory.
  3. A Repository where Git permanently stores those changes as different versions of the project.
git init -- creates a new Git repository
git status -- inspects the contents of the working directory and staging area
git add -- adds files from the working directory to the staging area
git diff -- shows the difference between the working directory and the staging area
git commit -- permanently stores file changes from the staging area in the repository
git log -- shows a list of all previous commits
git checkout HEAD filename -- discards changes in the working directory
git reset HEAD filename -- unstages file changes in the staging area
git reset SHA -- can be used to reset to a previous commit in your commit history
git branch -- lists all a Git project’s branches
git branch branch_name -- creates a new branch
git checkout branch_name -- used to switch from one branch to another
git merge branch_name -- used to join file changes from one branch to another
git branch -d branch_name -- deletes the branch specified
git clone -- creates a local copy of a remote
git remote -v -- lists a Git project’s remotes
git fetch -- fetches work from the remote into the local copy
git merge origin/master -- merges origin/master into your local branch
git push origin branch_name -- pushes a local branch to the origin remote

See Also

Choosing the Right Source Control

Git has become wildly popular as a version control system in the development community. Companies large and small, individuals, the open source community, and others swear by Git.

Is it the right source control system for you?

After reading the following infographic, I choose to stick with Subversion.

Choosing the Right Source Control
Choosing the Right Source Control