Content of /tricks/ section is open-source.
You're welcome to:
Content of /tricks/ section is open-source.
You're welcome to:
git grep "SEARCH_FOR" $(git rev-list --all)
git restore PATH_TO_FILE
git restore PATH_TO_FILE --source=HEAD~N
(available in Git 2.23+)
git clean -i
DEL_TAG=v1.0.0; git tag -d $DEL_TAG && git push origin --delete $DEL_TAG
Hidden feature in GitHub web editor: you can move a line of code up or down by holding Option (on Mac) or Alt (on Windows/Linux) and pressing the Up or Down arrow keys!
/r/TricksForGeeks/comments/1pk9wr6/automatically_sync_code_snippets_in_your_readme
brew install gh
# This pulls the legal text from GitHub's API and saves it as a file
gh repo license view CC-BY-SA-4.0 > LICENSE
PS: Smile 🤓 Git typo of the day:
git rest --hard
useConfigOnly, and conditional includeIf Exposing your commit email is easy; rewriting Git history is hard.
But there's a set-and-forget solution to ensure your Git privacy.
useConfigOnly = true in your Git configuration to prevent falling back to your system username/hostname (e.g., user@laptop.local). If no email is set in the config, the commit will simply fail, prompting you to fix it.[includeIf] block with **/*hostname.com/** as a powerful glob pattern to match both HTTPS (https://) and SSH (git@) remote URLs for the respective hosts. This forces Git to use the correct no-reply email based purely on the repository's remote URL.You'll need the following configuration files. Replace all PLACE_HOLDER values with your actual information.
_NOTE: You have to split the .gitconfig into multiple files to avoid issues with [includeIf], as explained in /a/74012889/5034198_
.gitconfig # ====================================================================
# Global Git Configuration
#
# To use this example:
# 1. Save this file as ~/.gitconfig (most common location)
# 2. Replace all PLACE_HOLDER values (e.g., YOUR_FULL_NAME)
# 3. Repeat for .gitconfig-github and .gitconfig-gitlab as necessary
# ====================================================================
[user]
# Set your default name for all commits.
name = YOUR_FULL_NAME
# CRITICAL: Prevents accidental exposure of system email if no
# specific email is found in the conditional blocks below.
useConfigOnly = true
# --------------------------------------------------------------------
# CONDITIONAL OVERRIDES
# These allow you to use different `user.email` based on the URL of
# the repository (e.g., work vs. personal, or GitHub vs. GitLab, etc.)
# --------------------------------------------------------------------
[includeIf "hasconfig:remote.*.url:**/*github.com/**"]
path = .gitconfig-github
[includeIf "hasconfig:remote.*.url:**/*gitlab.com/**"]
path = .gitconfig-gitlab
.gitconfig-github # ====================================================================
# GitHub-specific Git configuration
#
# To use this example:
# 1. Get your unique GitHub commit email: https://github.com/settings/emails#toggle_visibility_label
# 2. Copy this file next to your `~/.gitconfig` and replace email below
# ====================================================================
[user]
email = YOUR_GITHUB_ID+USERNAME@users.noreply.github.com
.gitconfig-gitlab # ====================================================================
# GitLab-specific Git configuration
#
# To use this example:
# 1. Get your unique GitLab commit email: https://gitlab.com/-/user_settings/profile#user_public_email
# 2. Copy this file next to your `~/.gitconfig` and replace email below
# ====================================================================
[user]
email = YOUR_GITLAB_ID-USERNAME@users.noreply.gitlab.com
git config user.email. It will show your respective GitHub/GitLab no-reply email.This simple solution ensures your privacy is protected and your commits are correctly attributed, regardless of which hosting platform you're working on.
Shouldn't this be the default configuration for every developer?
✨ if YOU found this useful — give a star on GitHub or simply join TricksForGeeks on Reddit for more ✨
© 2025–2026