Git Cheat Sheet - Git made easy

From Brian Nelson Ramblings
Revision as of 03:21, 16 January 2018 by Brian (Talk | contribs) (Git Cheat Sheet - Git made Easy)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Git Cheat Sheet - Git made Easy

Git is the most commonly used version control system today and is quickly becoming the standard for version control. Git is a distributed version control system, meaning your local copy of code is a complete version control repository. These fully-functional local repositories make it is easy to work offline or remotely. You commit your work locally, and then sync your copy of the repository with the copy on the server. This paradigm differs from centralized version control where clients must synchronize code with a server before creating new versions of code.

Git’s flexibility and popularity make it a great choice for any team. Many developers and college graduates already know how to use Git. Git’s user community has created many resources to train developers and Git’s popularity make it easy to get help when you need it.  Nearly every development environment has Git support and Git command line tools run on every major operating system.

Setup your own accounts

- https://github.com/
- https://bitbucket.org

Create and Clone

Create New repository

git init

Clone local repository

git clone /path/to/repo

Clone remote repository

git clone  username@host:/path/to/repo

Add and Remove Files

Add Changes

git add <filename>

Add All Files

git add *

Remove/Delete Files

git rm <filename>

Commit and Sync

Commit Changes

git commit -m "Comment update"

Push Changes to Remote Repo

git push origin master

Connect local repo to Remote repo

git remote add origin <server>

Update local repo with remote changes

git pull

Branches

Create New Branch

git checkout -b <branch>

Switch to Master Branch

git checkout master

Delete Branch

git branch -d <branch>

Push Branch to remote repo

git push origin <branch>