Skip to content

lahirukawijes/Github-Git-Cheat-Sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 

Repository files navigation

GitHub Git Cheat Sheet

Git is an open source distributed version control system that facilitates GitHub activities on your laptop or desktop. This cheat sheet will help you with commonly used Git command line instructions for quick reference.

Catalog

INSTALL GIT

For Windows users

  1. Download Git for Windows Setup
  2. Install Git through the setup. Usually all configurations can be left in default settings.

For macOS users

Download Git for Mac

For Linux users

Debian/Ubuntu

For the latest stable version for your release of Debian/Ubuntu

$ sudo apt-get update
$ sudo apt-get get install git

For Ubuntu, this PPA provides the latest stable upstream Git version

$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt update
$ sudo apt install git

Fedora

For releases up to Fedora 21

$ yum install git

For Fedora 22 and later

$ dnf install git

Gentoo

$ emerge --ask --verbose dev-vcs/git

Arch Linux

$ pacman -S git

HOW TO USE GIT

Windows
Right click on any location and click git bash.

Linux and Mac
Open Terminal to use git.

CONFIGURE TOOLING

Configure user information for all local repositories

Set the name you want attached to your commit transactions

$ git config --global user.name "[name]"

Set the email address you want attached to your commit transactions

$ git config --global user.email "[email address]"

CREATE REPOSITORIES

Start a new repository or obtain one from an existing URL

Create a new local repository with the specified name

$ git init [project-name]

Download a project and its entire version history

$ git clone [url]

MAKE CHANGES

Review edits and craft a commit transaction

List all new or modified files to be commited

$ git status

Show file differences not yet staged

$ git diff

Snapshot a file in preparation for versioning

$ git add [file]

Snapshot all files of the current directory in preparation for versioning

$ git add .

Unstage the file (reset), but preserve its contents

$ git reset [file]

Record file snapshots permanently in version history

$ git commit -m "[descriptive message]"

GROUP CHANGES

Name a series of commits and combine completed efforts

List all local branches in the current repository

$ git branch

Create a new branch

$ git branch [branch-name]

Switch to the specified branch and updates the working directory

$ git checkout [branch-name]

Combine the specified branch's history into the current branch

$ git merge [branch-name]

Delete the specified branch

$ git branch -d [branch-name]

REFACTOR FILENAMES

Relocate and remove versioned files

Deletes the file from the working directory and stages the deletion.

$ git rm [file]

Removes the file from version control but preserves the file locally.

$ git rm --cached [file]

Changes the file name and prepares it for commit.

$ git mv [file-original] [file-renamed]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published