Skip to content

Instantly share code, notes, and snippets.

@the100rabh
Forked from gregschoen/Git-Cheatsheet.md
Last active August 29, 2015 14:28
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 the100rabh/ab68636e0814ee1de959 to your computer and use it in GitHub Desktop.
Save the100rabh/ab68636e0814ee1de959 to your computer and use it in GitHub Desktop.
Cheatsheets

Cheatsheets

Git Reference

Configure Local Branch to have Proper User Credentials

git config user.name "Your Name Here"
git config user.email your@email.com

Branch feature1 set up to track remote branch refs/remotes/origin/master.

git branch --track feature1 origin/master

Files that are different between current branch and master

git diff --name-status origin/master..

This pulls out your most recent commit, putting the changes back into your working tree

git reset --soft HEAD^

Compare differences between 2 branches

git diff branch-a branch-b

Revert to previous revision (from master)

git checkout <commit-hash> path/to/file.ext

Copy file from different branch

git checkout branch-name -- /path/to/file.ext

Add Remote Branch

git push origin branch-a

Track Remote Branch

git checkout --track -b local-branch-name origin/remote-branch-name

or

git branch --track local-branch-name origin/remote-branch-name
git pull local-branch-name

Push Changes To Remote Branch

git push origin newfeature

Delete Remote Branch (2 different ways)

git push origin --delete [branch-name]

or

git push origin :branch-name

Resolving Update Conflicts - View Conflicts

git status

Fix conflicts and then:

git add path/to/file.ext
git rebase --continue

Stop/Reset Rebase

git rebase --abort

Revert Deleted and Committed File

git rev-list -n 1 HEAD -- <file_path>
git checkout <deleting_commit>^ -- <file_path>

List Files Changed After Commited and Pushed

git diff HEAD^ origin/master --name-status

cheatsheet

# h1
## h2
### h3 you may 'close' hashes ###
#### h4 (thru h6)

this is also an h1
======

this is also an h2
------

> blockquote style one la la la  
i am still part of this blockquote

> another style of marking up  
> blockquotes. this is email style  
> quoting. blockquotes can be nested.

these are all unordered lists:

	* proto		- proto		+ proto
	* exo		- exo		+ exo
	* auxo		- auxo		+ auxo

these are all ordered lists:

	1. proto	1. proto	1. proto
	2. exo		4. exo		+ exo
	3. auxo		3. auxo		+ auxo

horizontal rules: (three or more)

	* * *

	***

	*****

	- - -

	------------------------

a link:

	[link text](http://yoursite.com/ "title")

	[link text no title](http://anothersite.com/)

	<address@example.com> will obfuscate your link a bit

an image:

	![Alt text](/path/to/img.jpg "optional title")

	![Alt text](/path/to/img.jpg)

emphasis:

	*hello* or _hello_ produces italicized [em] text

	**hello** or __hello__ produces bold [strong] text

	\*how to surround text with actual asterisks\*


markdown provides backslash escapes for the following characters:

	\   backslash
	`   backtick
	*   asterisk
	_   underscore
	{}  curly braces
	[]  square brackets
	()  parentheses
	#   hash mark
	+   plus sign
	-   minus sign (hyphen)
	.   dot !   exclamation mark

Making a table ( Multimarkdown )

| Header    | Another Header       |
| --------- | -------------------- |
| Data      | More Data            |
| Extra     | Additional Data      |

MySQL Reference

Data Types

TINYINT (1 byte)

  • Signed 128 to 127
  • Unsigned 0 to 256

SMALLINT (2 bytes)

  • Signed -32,768 to 32,767
  • Unsigned 0 to 65,535

MEDIUMINT (3 bytes)

  • Signed -8,388,608 to 8,388,607
  • Unsigned 0 to 16,777,215

INT (4 bytes)

  • Signed -2,147,483,648 to 2,147,483,647
  • Unsigned 0 to 4,294,967,295

BIGINT (8 bytes)

  • Signed -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
  • Unsigned 0 to 18,446,744,073,709,551,615

DATE (3 bytes)

TIME (3 bytes)

DATETIME (8 bytes)

TIMESTAMP (4 bytes)

YEAR (1 byte)

Commands

Insert from Select Statement

INSERT INTO `new_table` (`id`) 
SELECT `id` FROM `old_table`;

Modify Field on Table

ALTER TABLE `table`
MODIFY `id` INT(10) UNSIGNED NOT NULL,
MODIFY `big_id` BIGINT(20) UNSIGNED NOT NULL;

Rename Table

RENAME TABLE `old_table` TO `new_table`;

Create Compressed Table

CREATE TABLE `new_table_compressed` (
	`id` int(10) UNSIGNED NOT NULL,
	PRIMARY KEY (`id`)
) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;

Compress Table

ALTER TABLE `table_compressed` ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment