mirror of
https://github.com/cheat/cheat.git
synced 2025-09-01 01:28:30 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
6b736083c3 | |||
b477df20b2 | |||
6304a65399 | |||
bc40ced2c1 | |||
74dfd51601 | |||
51b0b12663 | |||
ae45265317 | |||
97dd037538 | |||
402d15e8d8 |
@ -38,7 +38,7 @@ from docopt import docopt
|
||||
|
||||
if __name__ == '__main__':
|
||||
# parse the command-line options
|
||||
options = docopt(__doc__, version='cheat 2.1.9')
|
||||
options = docopt(__doc__, version='cheat 2.1.11')
|
||||
|
||||
# list directories
|
||||
if options['--directories']:
|
||||
|
5
cheat/cheatsheets/csplit
Normal file
5
cheat/cheatsheets/csplit
Normal file
@ -0,0 +1,5 @@
|
||||
# Split a file based on pattern
|
||||
csplit input.file '/PATTERN/'
|
||||
|
||||
# Use prefix/suffix to improve resulting file names
|
||||
csplit -f 'prefix-' -b '%d.extension' input.file '/PATTERN/' '{*}'
|
@ -1,2 +1,5 @@
|
||||
# Printout date in format suitable for affixing to file names
|
||||
# Print date in format suitable for affixing to file names
|
||||
date +"%Y%m%d_%H%M%S"
|
||||
|
||||
# Convert Unix timestamp to Date
|
||||
date -d @1440359821
|
||||
|
@ -1,4 +1,4 @@
|
||||
# To set your identify:
|
||||
# To set your identity:
|
||||
git config --global user.name "John Doe"
|
||||
git config --global user.email johndoe@example.com
|
||||
|
||||
@ -17,9 +17,17 @@ git commit -m "Your commit message"
|
||||
# To edit previous commit message
|
||||
git commit --amend
|
||||
|
||||
# Git commit in the past
|
||||
git commit --date="`date --date='2 day ago'`"
|
||||
git commit --date="Jun 13 18:30:25 IST 2015"
|
||||
# more recent versions of Git also support --date="2 days ago" directly
|
||||
|
||||
# To removed staged and working directory changes
|
||||
git reset --hard
|
||||
|
||||
# To go 2 commits back
|
||||
git reset --hard HEAD~2
|
||||
|
||||
# To remove untracked files
|
||||
git clean -f -d
|
||||
|
||||
@ -35,6 +43,9 @@ git push git@github.com:username/project.git
|
||||
# To delete the branch "branch_name"
|
||||
git branch -D branch_name
|
||||
|
||||
# To make an exisiting branch track a remote branch
|
||||
git branch -u upstream/foo
|
||||
|
||||
# To see who commited which line in a file
|
||||
git blame filename
|
||||
|
||||
@ -57,3 +68,21 @@ git log --pretty=email --patch-with-stat --reverse --full-index -- Admin\*.py >
|
||||
|
||||
# Import commits from another repo
|
||||
git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout <commit SHA> | git am -3 -k
|
||||
|
||||
# View commits that will be pushed
|
||||
git log @{u}..
|
||||
|
||||
# View changes that are new on a feature branch
|
||||
git log -p feature --not master
|
||||
git diff master...feature
|
||||
|
||||
# Interactive rebase for the last 7 commits
|
||||
git rebase -i @~7
|
||||
|
||||
# Diff files WITHOUT considering them a part of git
|
||||
# This can be used to diff files that are not in a git repo!
|
||||
git diff --no-index path/to/file/A path/to/file/B
|
||||
|
||||
# To pull changes while overwriting any local commits
|
||||
git fetch --all
|
||||
git reset --hard origin/master
|
||||
|
@ -1,13 +1,13 @@
|
||||
# Basic:
|
||||
# Search a file for a pattern
|
||||
grep pattern file
|
||||
|
||||
# case nonsensitive research:
|
||||
grep -i pattern file
|
||||
# Case insensitive search (with line numbers)
|
||||
grep -in pattern file
|
||||
|
||||
# Recursively grep for string <pattern> in folder:
|
||||
grep -R pattern folder
|
||||
|
||||
# Getting pattern from file (one by line):
|
||||
# Read search patterns from a file (one per line)
|
||||
grep -f pattern_file file
|
||||
|
||||
# Find lines NOT containing pattern
|
||||
@ -17,7 +17,7 @@ grep -v pattern file
|
||||
grep "^00" file #Match lines starting with 00
|
||||
grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" file #Find IP add
|
||||
|
||||
# Find all files who contain {pattern} in the directory {directory}.
|
||||
# Find all files which match {pattern} in {directory}
|
||||
# This will show: "file:line my research"
|
||||
grep -rnw 'directory' -e "pattern"
|
||||
|
||||
|
@ -1,2 +1,5 @@
|
||||
# To create a symlink:
|
||||
ln -s path/to/the/target/directory name-of-symlink
|
||||
|
||||
# Symlink, while overwriting existing destination files
|
||||
ln -sf /some/dir/exec /usr/bin/exec
|
||||
|
5
cheat/cheatsheets/man
Normal file
5
cheat/cheatsheets/man
Normal file
@ -0,0 +1,5 @@
|
||||
# Convert a man page to pdf
|
||||
man -t bash | ps2pdf - bash.pdf
|
||||
|
||||
# View the ascii chart
|
||||
man 7 ascii
|
2
cheat/cheatsheets/numfmt
Normal file
2
cheat/cheatsheets/numfmt
Normal file
@ -0,0 +1,2 @@
|
||||
# Convert bytes to Human readable format
|
||||
numfmt --to=iec --suffix=B --padding=7 1048576
|
Reference in New Issue
Block a user