Skip to content

Instantly share code, notes, and snippets.

View williamluisan's full-sized avatar

William Luisan williamluisan

View GitHub Profile
@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)
@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 .
(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 / gist:0f14ec7d9eee885cbe33098f207e09ae
Created July 2, 2020 09:36
GIt prune remote branch on local (branch -r)
git fetch --prune origin
git describe --abbrev=0 --tags
@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'
@williamluisan
williamluisan / gist:c9b46ab28017f3d1300a4981ecdd94bf
Created July 12, 2021 08:22
(unix) Search file inside folder
find . -name "foo*"
@williamluisan
williamluisan / docker_container_connect_dir.txt
Last active August 1, 2021 06:41
Docker container connect directory
docker container create --name {name} -p 8080:80 -v /my/own/code/dir:/var/www/site {image}
@williamluisan
williamluisan / git_assume_not_changed.txt
Last active September 16, 2022 06:22
Tells git to assume that file not changed
git update-index --assume-unchanged [path]
Details:
https://luisdalmolin.dev/blog/ignoring-files-in-git-without-gitignore/
http://source.kohlerville.com/2009/02/untrack-files-in-git/
[
{"name": "Afghanistan", "code": "AF"},
{"name": "Åland Islands", "code": "AX"},
{"name": "Albania", "code": "AL"},
{"name": "Algeria", "code": "DZ"},
{"name": "American Samoa", "code": "AS"},
{"name": "AndorrA", "code": "AD"},
{"name": "Angola", "code": "AO"},
{"name": "Anguilla", "code": "AI"},
{"name": "Antarctica", "code": "AQ"},