Skip to content

Instantly share code, notes, and snippets.

View williamluisan's full-sized avatar

William Luisan williamluisan

View GitHub Profile
@williamluisan
williamluisan / gist:888e834a6a767ce80a7e98e5757198a1
Created May 10, 2021 16:49
An example of replacing chars at the left of SQL string
REPLACE('62', SUBSTR(service_number, 1, 2), CONCAT('0', SUBSTR(service_number, 3, 9999)))
# Result:
## From '6282190872222' to '082190872222'
git describe --abbrev=0 --tags
@williamluisan
williamluisan / gist:0f14ec7d9eee885cbe33098f207e09ae
Created July 2, 2020 09:36
GIt prune remote branch on local (branch -r)
git fetch --prune origin
(unix-like)
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
(linux)
git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -d
(windows)
git branch --merged | Select-String -Pattern "develop" -NotMatch | ForEach-Object {git push origin --delete "$_".Trim(); git branch -d "$_".Trim()}
@williamluisan
williamluisan / gitignore_reset.txt
Last active April 3, 2021 09:01
Gitignore reset cache
### STEP 1 ###
Adding "your path to file" you want to ignore in .gitignore
### STEP 2 ###
(choose one of the options)
# option(1) (recommended) Remove the cache of all the files
git rm -r --cached .
@williamluisan
williamluisan / git_compare_and_archive.txt
Last active April 12, 2022 14:11
Git compare commit and make archive.
## Archive between tag
git archive -o <app_name>v<version>.zip HEAD $(git diff v<version> v<version> --name-only)
## Archive on specific commit
git archive -o <app_name>v<version>.zip HEAD $(git diff COMMIT~ COMMIT --name-only)