Skip to content

Instantly share code, notes, and snippets.

@emrecamasuvi
Last active November 6, 2020 08:08
Show Gist options
  • Save emrecamasuvi/d4247b0b469a5a44729b to your computer and use it in GitHub Desktop.
Save emrecamasuvi/d4247b0b469a5a44729b to your computer and use it in GitHub Desktop.
terminal git cmd bash etc
# To recursively give directories read&execute privileges:
find /path/to/base/dir -type d -exec chmod 755 {} +
# To recursively give files read privileges:
find /path/to/base/dir -type f -exec chmod 644 {} +
# Or, if there are many objects to process:
chmod 755 $(find /path/to/base/dir -type d)
chmod 644 $(find /path/to/base/dir -type f)
# Or, to reduce chmod spawning:
find /path/to/base/dir -type d -print0 | xargs -0 chmod 755
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644
sudo chown -R $USER /usr/local
sudo chown -R emre:emre root_tobe_user.txt
# monitor system
iotop powertop nethogs
# monitor node processes
ps aux | grep node
# Grep and Find search
# n: numberline r: recursive v: inverted i: casesensitive
grep -nr "search-term" site_media/css/correct/path | more
find . -iname *.py | xargs grep "aranacak_kelime" -sl
# unzip tar file to folder
tar -xfvz file_name.tar.gz -C /tmp/
# remove pyc files from project
find . -name '*.pyc' -delete
# list files before removal
find . -name '*fullpage_volders_Max_Recover_Password_-_Check_Your_Email_*' -type f
# remove files filtered
find . -name '*fullpage_volders_Max_Recover_Password_-_Check_Your_Email_*' -type f -delete
# List all CSS files
find . -type f -name *.css
# List all CSS or HTML files
find . -type f \( -name "*.css" -or -name "*.html" \)
# In order to ignore changed files to being listed as modified, you can use the following git command:
git update-index --assume-unchanged <file>
# To revert that ignorance use the following command:
git update-index --no-assume-unchanged <file>
# accidentally added file to the repo and stop tracking now. after *.log => .gitignore
git rm --cached application.log
# Rename local branch
git branch -m oldname newname
# <<< OR in branch >>>
git branch -m newname
# Restore a deleted file
git rev-list -n 1 HEAD -- filename
git checkout deletingcommitid^ -- filename
# Revert a single file to a specific previous commit
git checkout commitid filename
# see whats inside commit file
git cat-file commit <SHA>
git ls-tree tree <treeSHA>
git cat-file blob <blobSHA>
# get a file from a specific revision
git show HEAD~4:index.html
# (not yet pushed) RESET options
# STAGED Undo "local" changes w/o any commit
git checkout -- <bad filename>
# Discard ALL unchecked in changes
git checkout -- .
# COMMITTED => UNSTAGED Undo the last Git commit? <SHA>
git reset 'HEAD^'
# <<< OR >>>
git reset --mixed 'HEAD^'
# COMMITTED => STAGED Undo the last Git commit? <SHA>
git reset --soft 'HEAD^'
# COMMITTED <<< NUKER >>>> Undo the last Git commit w/o stage files? <SHA>
git reset --hard 'HEAD^'
# Over-write local files when doing a git pull
git fetch --all
git reset --hard origin/master
# undo a merge
git reset --merge ORIG_HEAD
# Undo a "public" change after git push
git revert <SHA> + git push
# Fix the last commit message
git commit --amend
# <<< or >>>
git commit --amend -m "Fixes bug #42"
# stash untracked files as well
git stash --include-untracked
# find all branches that have already been merged into master
git branch --merged=master
# Redo after undo "local" made some commits, did a git reset --hard to "undo" those changes (see above), and then realized: you want those changes back!
git reflog and (git reset) or (git checkout)
# made some commits, then realized you were checked out on master
git branch feature
git reset --hard origin/master
git checkout feature
# git branch feature creates a new branch called feature pointing at your most recent commit, but leaves you checked out to master.
# Create a branch from a previous commit
git branch branchname <SHA>
# <<< or >>>
git checkout -b branchname <SHA>
# delete branch remote
git push <REMOTE> --delete <branchName>
# <<< or >>>
git push <REMOTE> :branchName
# delete branch remote
git branch -d <branchName>
# See with tig which git commits touch a file or files or folders
tig path_to_file_or_files_or_path_with_wildcard
# Display changes for a single file:
tig -- README
# Display one or more specific branches:
tig feature master
# Display revisions between two dates for a specific file
tig --after="2004-01-01" --before="2006-05-16" -- README
tig
A # display user options
D # display date options
H # view branchs' content
g # toggle revision graph visual
l # show log view
t # tree view
B # (select file) blame view
# git clean tip before pull req
### Checkout the feature branch
git checkout feature/superAmazing
### start interactive rebase session
git rebase -i master
### screen1
pick dae2691 add amazing feature
pick 3491879 add test
pick 3fedbd5 fix typo
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
### screen2
pick dae2691 add amazing feature
squash 3491879 add test
squash 3fedbd5 fix typo
### screen 3
After editing the file you need to save it and provide a last new commit message for the merge. The last thing to do, is to push the changes.
Note: While rebasing we have to use the force flag like "git push -f" in order to perform a push!
credits: http://christoph-rumpel.com/2015/05/clean-up-your-commits-for-a-pull-request/
# gulp, grunt free build w/ package.json
npm install --save-dev node-sass
npm install --save-dev postcss-cli autoprefixer
npm i -D eslint (same as npm install --save-dev eslint)
eslint --init (so that creates config in root)
npm i -D uglify-js
npm i -D imagemin-cli
npm i -D browser-sync
npm i -D onchange
npm i -D parallelshell
# and package.json looks like
{
"name": "npm-build-boilerplate",
"version": "1.0.0",
"scripts": {
"scss": "node-sass --output-style compressed -o dist/css src/scss",
"min-sass": "node-sass resources/sass/main.scss | cleancss -o public/stylesheets/main.min.css –source-map",
"autoprefixer": "postcss -u autoprefixer -r dist/css/*",
### or ###
### npm run autoprefixer ###
"autoprefixer": "postcss -u autoprefixer --autoprefixer.browsers '&gt; 5%, ie 9' -r dist/css/*",
"lint": "eslint src/js",
"uglify": "mkdir -p dist/js && uglifyjs src/js/*.js -m -o dist/js/app.js && uglifyjs src/js/*.js -m -c -o dist/js/app.min.js",
### mkdir -p dist/js says: Create a folder structure (mkdir), but only if it doesn't exist already (-p flag) ###
"imagemin": "imagemin src/images dist/images -p",
### The -p flag is passed to create "progressive" images when possible. ###
"serve": "browser-sync start --server --files 'dist/css/*.css, dist/js/*.js'",
"build:css": "npm run scss && npm run autoprefixer",
### combines the two CSS related tasks (preprocessing Sass and running Autoprefixer ###
"build:js": "npm run lint && npm run uglify",
"build:images": "npm run imagemin && npm run icons",
"build:all": "npm run build:css && npm run build:js && npm run build:images",
"watch:css": "onchange 'src/scss/*.scss' -- npm run build:css",
"watch:js": "onchange 'src/js/*.js' -- npm run build:js",
"watch:all": "parallelshell 'npm run serve' 'npm run watch:css' 'npm run watch:js'"
},
"devDependencies": {
...
}
}
# PS
# Instead of parallelshell, try npm-run-all
# allows for globbing of tasks when executing them
# cachebusting https://www.npmjs.com/package/hashmark
# Compiling + watching Sass with npm scripts is dreadfully slow. gulp is much, much faster
# credits to https://css-tricks.com/why-npm-scripts/ Damon Bauer
# Hotkeys
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment