Skip to content

Instantly share code, notes, and snippets.

@gringoh
gringoh / git-remove-files-gitignore.md
Last active July 1, 2022 12:28
[Git: Remove files after updating .gitignore] #git

Git: Remove files after updating .gitignore

Here, we're removing all files that are currently being ignored in .gitignore:

git rm -r --cached .
git add .
git commit -m "Removes all .gitignore files and folders"
@gringoh
gringoh / git-stash-unstaged-changes.md
Last active May 12, 2021 13:39
[Git: Stash unstaged changes] #git

Git: Stash unstaged changes

This will stash all modifications that you did not git add:

git stash -k

Note that newly created (and non-added) files will remain in your working directory unless you also use the -u switch.

git stash -k -u
@gringoh
gringoh / git-username-and-email.md
Last active May 10, 2022 18:57
[Git: change user and mail] #git

Change git username and email

To set your global username/email configuration

git config --global user.name "FIRST_NAME LAST_NAME"
git config --global user.email "[email protected]"

To set repository-specific username/email configuration:

@gringoh
gringoh / bash-delete-dot-files-recursively.sh
Last active May 13, 2020 15:21
[bash: Delete dot files recursively] #bash
find . -name ".*" -print
# I don't know the MAC OS, but that is how you find them all in most *nix environments.
find . -name ".*" -exec rm -rf {} \;
# to get rid of them... do the first find and make sure that list is what you want before you delete them all.
# The first "." means from your current directory. Also note the second ".*" can be changed to ".svn*" or any other more specific name; the syntax above just finds all hidden files, but you can be more selective. I use this all the time to remove all of the .svn directories in old code.
@gringoh
gringoh / git-move-commits.md
Created May 13, 2020 14:06
[git: Move commits to another branch] #git

Moving to an existing branch

If you want to move your commits to an existing branch, it will look like this:

git checkout existingbranch
git merge master         # Bring the commits here
git checkout master
git reset --keep HEAD~3  # Move master back by 3 commits.
git checkout existingbranch

The --keep option preserves any uncommitted changes that you might have in unrelated files, or aborts if those changes would have to be overwritten -- similarly to what git checkout does. If it aborts, git stash your changes and retry, or use --hard to lose the changes (even from files that didn't change between the commits!)

@gringoh
gringoh / mvn-run-spring-boot.sh
Created May 8, 2020 11:48
[mvn: Run Spring Boot Project] #mvn #spring
mvn spring-boot:run
@gringoh
gringoh / pod-update.sh
Created May 8, 2020 11:47
[pod: update pods] #ios #cocoapods
pod update && pod install
@gringoh
gringoh / git-undo-commit.md
Created May 8, 2020 11:39
[git: Undo commit not pushed] #git
@gringoh
gringoh / git-push-local-branch.md
Created May 8, 2020 11:37
[git: Push local branch] #git

Pull local branch to origin

Create a new branch:

git checkout -b feature_branch_name

Edit, add and commit your files.

Push your branch to the remote repository:

@gringoh
gringoh / flutter-dart-jwt-decode.dart
Last active May 12, 2022 14:54
[Dart: decode JWT token] #dart #flutter
_decodeJwt(String jwt) {
final parts = jwt.split('.');
if (parts.length != 3) {
throw Exception('invalid token');
}
final payload = _decodeBase64(parts[1]);
final payloadMap = json.decode(payload);
if (payloadMap is! Map<String, dynamic>) {
throw Exception('invalid payload');