Skip to content

Instantly share code, notes, and snippets.

@oDinZu
Last active October 9, 2017 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oDinZu/0ebd2a50dd83329cce66328e95c0052f to your computer and use it in GitHub Desktop.
Save oDinZu/0ebd2a50dd83329cce66328e95c0052f to your computer and use it in GitHub Desktop.
A cheat sheet for getting started with Git

Install Git:

https://git-scm.com/docs/git-help

Setup Config Values (Global):

git config --global user.name "Name Example"

git config --global user.email "email@gmail.com"

git config --list (list config values in terminal)

Help & Examples:

git help config

git add --help

Setup Own Project Local Repo: Not needed if working on remote origin

mkdir Folder

cd Folder

git init (initilize new repo)

Before First Commit:

git status

touch .testfile (creates a test file)

Save file

git status

git log (List details of all commits in local repo)

Staging Area / Changing Files:

git diff

git status

git add -A (Adds all files to staging area)

git commit -m "detailed message goes here"

git reset (only use to reset staging area i.e, added uneeded file)

Working with Remote Repo's:

git clone https://github.com/user/repo.git (clones a copy of remote repo to local)

git pull origin master (Update remote branch)

git push origin master (Push to remote)

Creating Local Branches / Checkout that Branch:

git branch (list branches)

git branch new-branch (Creates copy of master and renames)

git checkout new-branch (Goes to local created branch)

git branch

Adding / Commiting Files: Very important to be as descriptive as possible as here

git status

git add -A (Adds all files to staging area)

git commit -m "detailed message goes here"

Pushing new-branch to remote:

git push -u origin new-branch (Pushes to origin and sets up a simple git push git pull and know two branches are associated with each other)

git branch -a (see all branches, including remote)

Git Remote Add Own Upstream from new remote:

git remote add upstream https://github.com/user/name.git

Remove Upstream:

git remote remove upstream

Merge A Branch to Master:

git checkout master

git pull origin master (Important to do in case another has made changes to the master remote)

git branch --merged

git merge new-branch

git push origin master

git branch --merged

Delete the Local Branch if Needed:

git branch -d new-branch

git branch -a (check branch has been deleted)

Delete Branch from remote repo:

git push origin --delete calc-divide

Setup GPG Verified Key for GitHub:

https://help.github.com/articles/signing-commits-with-gpg/

https://help.github.com/articles/generating-a-new-gpg-key/

https://help.github.com/articles/adding-a-new-gpg-key-to-your-github-account

https://help.github.com/articles/telling-git-about-your-gpg-key/

https://help.github.com/articles/checking-for-existing-gpg-keys/

Git Documentation:

https://git-scm.com/docs/git-help

HushPup Developer / Testing:

https://github.com/MyHush/hush/tree/master/contrib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment