Git Setup for a New Project: A Complete Step-by-Step Guide

2 minute
276 words
Categories:
Web Development
Tags:

Introduction

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is a tool that tracks every change you make to your code, like a timeline. If something breaks, you can always go back to an earlier working version. It allows multiple developers to collaborate on a project efficiently without overwriting each other’s work, by maintaining a complete history of all modifications.

The Three States in Git

Git has three main states that files can reside in:

  • Modified: Modified means the file has been changed, but the changes are not committed to Git yet.
  • Staged: Staged means that you have marked a modified file in its current version to go into your next commit snapshot.
  • Committed: Committed means that the data is safely stored in your local database.

Installing Git

Download Git from https://git-scm.com/ and add to PATH.

Git Cheat Sheet

Getting Started

Command Description
git init Start a new repo
git clone Clone an existing repo

Prepare to Commit

Command Description
git add Add untracked file or unstaged changes
git add . Add all untracked files and unstaged changes
git add -p Choose which parts of a file to stage
git mv Move file
git rm Delete file
git rm –cached Tell Git to forget about a file without deleting it
git reset Unstage one file
git reset Unstage everything
git status Check what you added

Configure Git

Command Description
git config user.name ‘Your Name’ Set a config option
git add . Set option globally
git config alias.st status Add an alias
man git-config See all possible config options

Previous

How to create multiline text underline animation in css

Next

A Collection of Opensource Javascript libraries