Extended Regular Expression Cheat Sheet



Although there are enough resources on the web about Git, I will keep this one for my own reference. Minimal Git version required 1.7.2.

TOC

Legend

Run grep with extended regular expressions.-i Ignore case (ie uppercase, lowercase letters).-v Return all lines which don't match the pattern.-w Select only matches that form whole words.-c Print a count of matching lines. Can be combined with the -v option to print a count of non matchine lines.-l Print the name of each file which contains a match.

  • index: staging area (Imagine you are loading sand into the truck with bucket. Well, the bucket is like index and truck like a repository :)
  • <sha1>: sha1 hash of commit
  • <file>: path to the file (path/to/file.ext)
  • <branch>: branch name
  • <repository>: remote repository name

Info

  • General Regular Expression Processor Oper ation Option Exam ple Find a string in 1 or more files grep 'string' filename1 filename2. Filena men Case insens itive search i grep -i 'string' filename Use regular expres sions (regex) grep 'regex' filename Look for words w grep -w 'word' filename.
  • PHP PCRE Cheat Sheet Functions pregmatch(pattern, subject, submatches) pregmatchall(pattern, subject, submatches) pregreplace(pattern, replacement, subject) pregreplacecallback(pattern, callback, subject) preggrep(pattern, array) pregsplit(pattern, subject) Base Character Classes w Any “word” character (a-z 0-9 ).
  • Grep Cheat Sheet Escaped Values Autopsy uses the grep utility to search an image. Grep requires that some values be 'escaped' if they are searched for. Autopsy will automatically escape those values if the serach is being done for a non-regular expression.The escaped values include.

Search the history for a change matching a pattern

Useful options:

Find commits where files were deleted

Cheat

Checkout deleted file in the working tree

Checkout a file from another branch into the working tree

Only show the content of a file from a specific revision

Show diff between branches detecting renames

Show file's history

Show changes on a branch that is not merged upstream

Show log with changed files

Get latest tag in the current branch

Find out if a change is part of a release

Find out which branch contains a change

Adding

Add changes to the index chunk by chunk

  • y: stage this chunk
  • n: do not stage this chunk
  • s: split this chunk into smaller chunks
  • e: edit this chunk

Branching

Create local branch

If not provided, Git uses HEAD as the new branch start point.

or

Delete local branch

Delete already merged branch Com1 driver.

Force branch deletion

Patching

Copy commit range from one branch to another

Pick from start <sha1> commit till end <sha1> Axium driver download. commit.

Creating and applying patches

By default Git will create a patch for every commit. Use --stdout > <patch>.patch for combined patch.

Create patches for the last N commits (each commit in it's own patch).

Create patches containing all commits from the current branch against another <branch> branch (each commit in it's own patch).

Creating combined patch.

Extended Regular Expression Cheat Sheet

Check what changes are in the patch Codes rousseau usb devices driver.

Test the patch before applying

Apply patch

Undoing

git reset contains great explanation and examples.

Split commit

--soft option will keep files in the index.

Regex Cheat Sheets

Undo a merge or pull

Undo a merge or pull inside a dirty work tree

Revert a bad commit

Checkout a deleted file into the work tree

Remotes

Crete a new local branch by pulling a remote branch

Track a remote branch with an existing local

Delete remote branch

Prune remote-tracking branches that are deleted from a remote repo

Change remote URL

Subtree

  • --squash do not preserve history (squash history)

Add subtree as non-remote repository

Add subtree

Pull subtree

Add subtree as remote repository

Add remote

Sheet

Add subtree

Pull subtree changes

Push subtree changes

Submodules

Extended Regular Expression Cheat Sheet Pdf

Update submodules

Update submodule's URL

Edit the .gitmodules file, then run:

Remove submodule

  • remove the submodule's entry in the .gitmodules file
  • remove the submodule's entry in the .git/config
  • run git rm –cached path/to/module - without a trailing slash!
  • remove the submodule from the filesystem, run rm -rf path/to/module/
  • commit changes

Extended Regular Expression Cheat Sheet

Additional resources