Git Commands;

GitHub error(can’t push to github public key) –

$ git reset --hard 1e45d (Deletes the commit after you selected or moves the branch pointer to where you decide to go)

# equivalent to svn revert, If you want to throw out all of the changes you’ve been working on
$ git reset --hard

# reset/undo a single file, revert
$ git checkout -- [filename]

#go back one commit
$ git reset [branch]~1

#undo the commit
# without auto commit
$ git revert -n 1sdf34
# with auto commit
$ git revert 1sdf34

$ git branch -d [path] # delete branch
$ git push origin --delete [branch_name] # delete remote branch
$ git push origin master-testing:master-testing # push to a branch that is not currently checked out
$ git branch -a #show all branch local and remote
$ git branch -rd public/master # removes remote branch
$ git branch [branch name] (creates branch but doesn't check it out)
$ git checkout -b [branch name] (shortcut: creates branch and checks it out)
$ git checkout -b new_database upstream/new_database (creates branch, checks it out and track from upstream)
$ git branch -u [remote] [branch name] (set current branch upstream)

# this will go to that commit but you will be in a no name branch
$ git checkout fa15gvwsgc

# get a specific file from another branch into current branch
git checkout [branch] [file_path]

# clone and checkout only a file

# to remove the red delete: not the whole directory system, stage the deleted files
$ git add -u

# add parts of the file, chucks
$ git add -p

#to remove from stage or untrack a file
$ git rm --cached -f <file name>

$ git branch (check branches and which one your in)
$ git diff branch1 branch2 (show what line of code has been changed or git difftool)

# Show git diff on file in staging area, view code that is going to be committed
$ git diff --staged

# difference between file in 2 different branches
git difftool [branch1] [branch2] — [file]
git diff [branch1] [branch2] — [file]

# Showing which files are different in 2 branchesf
git diff –name-status [branch1] [branch2]

$ git commit -am [commit description] (shortcut: this allows you to add (-a) and name the commit (-m) all at once)

$ git config --global color.ui true (set git to be colorful)

$ git clone git:// #read Only - (this downloads a folder(directory) from github on to your computer. to work with it you need to change the directory(cd))
$ git clone username@
$ git clone server:/path [custom folder name]
$ git clone -o [custom name]

# git inside another git
# view all submodules
$ git submodule
$ git submodule add [name/path]
# update to newest remote commit, will unbranch
$ git submodule update --remote [repository]
$ git submodule update --init
# easy way pull latest of all submodules
$ git submodule foreach git pull origin master

# remove submodule
$ git submodule deinit [submodule name]
$ git rm [submodule name]

pull == fetch + merge #stick with fetch and merge, pull may throw error if you dont know what you doing. Like trying to pull anything other than the master branch

$ git log --online --graph --all --decorate # a nice/pretty way to see the git log
$ git log --pretty=format:"%an %h" (formats the log output to your liking)

# reachable different between two branches
# what commits hasn’t been merged into master
# what commits is in branchA that is not merged into master yet? is there anything unique
$ git log branchA ^master

# shows how many lines were change by the plus and minus symbol
$ git log --stat

# shows what was changed (diff) in each file/commit ( 2 first commits )
$ git log -p -2

# show log tree of only local branches
$ git log --branches --not --remotes

# show log tree of only remote branches
$ git log --branches --remotes

# show log of branches by regular expression
$ git log --branches=version1*

# show log of branches by regular expression
$ git log --branches=version1*

# Look for differences whose patch text contains added/removed lines that match, regular expression (regex)
$ git log -G fsq*

# commits per user
$ git shortlog -sne

# show git settings
$ git config --list

#set alias
$ git config --global "log --oneline --graph --decorate"

#set alias with date,
$ git config --global "log --graph --pretty=format:'%Cred%h%Creset %Cgreen%cr%C(yellow)%d%Creset %s %C(bold blue)<%an>%Creset'"

$ git stash save "name" #saves the current state without having to commit see
$ git stash list #shows your stashes
$ git stash apply stash@{1} #apply you save stash

# video on how to set up your own git server like github –

#when pushing to the server make sure your not in the branch your pushing to
# its located in the .git/config line 10
# make sure you have permission to .git folder (sudo chgrp)
$ git remote add origin
#removes origin, so you can change it. file location is => /.git/config
$ git remote rm origin

# rename a remote
$ git remote rename <old> <new>

#creates an alias
$ git push origin [branch Name] or $ git push origin --all
$ git fetch origin [branch Name]

# I tried to tie htdocs in lampp a server and was getting an error when I push because I had to change the owners from root to username. I ran
$ chown username -R htdocs

#git mergetool set which one you want to use/candidates
$ git mergetool -t <candiatename>

# instrustions on how to use kdiff3 –

# merge a specific/selected commit/file/changes –
$ git cherry-pick 5d3e1b6

# only merge if theres no conflict, fast forward
$ git merge --ff-only [branch]

# Git command line for merging without committing

git merge --no-commit --no-ff branchB

$ git reset --merge #cancel the merge

# want to change the order of commits, add additional one, combine, previous, remove/delete
$ git rebase -i [branch]~[number of commits]
# if confict you may need to $ git mergetool
$ git rebase --continue # to continue with rebase
$ git rebase --abort # to quit rebase

#when on a different branch
$ git rebase [name of branch to go under current checked out branch]

#how many commits per file
$ git ls-files | xargs wc -l

#adding patches in git
#on the new branch

$ git format-patch master --stdout > newpatch.patch #what this does is get the difference between the branches into a text file

#back on the master branch

$ git am < newpatch.patch

#if error
$git am --skip

# adding patch 2
# on test branch
$ git diff ..master > master.patch
$ git apply master.patch

#rename a commit
git commit –amend
git commit –amend -m “Your new message here”

#unstage a file
git reset — <file>
$ git tag
$ git tag v2.0

# when trying to git clone a repository in github so you can edit(ssh) on a new computer you need to create a key
$ ssh-keygen
Enter file in which to save the key (/home/sock/.ssh/id_rsa): (enter)
Enter passphrase (empty for no passphrase): (enter)
Enter same passphrase again: (enter)
#get key:
$cat ~/.ssh/
#then go to and add the ssh key

#serving git
$ git push web +master:refs/heads/master

There are two types of repositories: bare and non-bare
non-bare you cannot push to a working copy, thus: [remote rejected] master -> master (branch is currently checked out), cannot push to master

Bare repositories do not have a working copy and you can only push, pull and fetch to them.
Those are the types of repositories you get in Github! If you want to create a bare repository, you can use

$ git init --bare

to change from normal to bare

$ git config --bool core.bare true

# add this block of code to the end of .git/config to not have to specify the branch and remote repository
# everytime you push or pull
[branch “master”]
remote = server
merge = refs/heads/master

# Find/Search a String in the Entire Git History
git rev-list --all | xargs git grep -F ''

# removing sensitive data, passwords, keys and things like that–net-29799#highlighter_961797

# good resource:–net-29799

# host git on dropbox

### using git to deploy to production server

Google API maps example/snippet

Google API maps example/snippet:

<script type="text/javascript" src=""></script>			

" ((ACOS(SIN($lat * PI() / 180) * SIN(this.latitude * PI() / 180) + COS($lat * PI() / 180) * COS(this.latitude * PI() / 180) * COS(($lng - this.longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) "; 

* uses google API to get location in the search text input 
* @author 2013-06-25

function searchLocations() {
    var deferred = $.Deferred();
    var address = $("#te_qkeywords").val();
    var geocoder = new google.maps.Geocoder();

    geocoder.geocode({address: address}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            var latitude = results[0].geometry.location.nb;
            var longitude = results[0].geometry.location.ob;


            if(latitude == undefined || longitude == undefined){
              console.log('%c FSQ ERROR: latitude or longitude is blank', 'color: red');

        } else {
            alert(address + ' not found');
    return deferred;




<script type="text/javascript">
	Google Map API, 2013-07-01

var get_coordinate = function(coordinate){
		var str = document.URL;

		var n =;
		var http_request = str.substring(n);
		var and_sign ='&');
		var equal_sign ='=');
		return http_request.substring(equal_sign+1,and_sign);

var me = new google.maps.LatLng(get_coordinate('latitude'),get_coordinate('longitude'));

var fit_all_markers_in_map = new google.maps.LatLngBounds();

var map = new google.maps.Map(document.getElementById('map'), {
  zoom: 10,
  //center: new google.maps.LatLng(-33.92, 151.25), //default location
  mapTypeId: google.maps.MapTypeId.ROADMAP

var infowindow = new google.maps.InfoWindow();
var marker_position = [];
var distance_between_search = [];
var meters_to_miles = 0.000621371;
var marker, i;

for (i = 0; i < locations.length; i++) {  
    marker = new google.maps.Marker({
    position: new google.maps.LatLng(locations[i][1], locations[i][2]),
    map: map,
    icon: locations[i][3],
  distance_between_search[i] = google.maps.geometry.spherical.computeDistanceBetween( me, marker.position ) * meters_to_miles;
  marker_position[i] = marker.position;
  //check if there a http request
  if ('latitude') > -1 ){
  	$('#distance' + (i+1)).html(parseFloat(distance_between_search[i]).toFixed(2) + ' miles');


  google.maps.event.addListener(marker, 'click', (function(marker, i) {
    return function() {
      infowindow.setContent(locations[i][0]);, marker);
  })(marker, i));


var zoom_and_pan_to_marker = (function(){
	$('tr').hover(function() {