Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Tag: git best practices

Git

Git Hooks Automation: Pre-commit Checks That Save Hours of Debugging

- 05.02.26 - ErcanOPAK comment on Git Hooks Automation: Pre-commit Checks That Save Hours of Debugging

Tired of catching bugs in code review? Git hooks automatically validate code before it even reaches the repository. #!/bin/bash # .git/hooks/pre-commit # Exit immediately if any command fails set -e echo “🚀 Running pre-commit checks…” # 1. Check for debugging statements echo “🔍 Checking for console.log statements…” if git diff –cached –name-only | xargs grep […]

Read More
Git

Git Rebase Magic: How to Clean Up Messy Commit History Like a Pro

- 05.02.26 - ErcanOPAK comment on Git Rebase Magic: How to Clean Up Messy Commit History Like a Pro

Your git history looking like a war zone? Interactive rebase transforms chaotic commits into a clean, logical story. The Problem: Spaghetti Commit History # Typical messy history $ git log –oneline a1b2c3d Fix typo in README e4f5g6h Update config again h7i8j9k Another attempt k0l1m2n Revert previous change n3o4p5q Merge branch ‘feature-x’ p6q7r8s WIP: trying something […]

Read More
Git

Git: Find and Remove Sensitive Data from Entire Repository History

- 03.02.26 - ErcanOPAK comment on Git: Find and Remove Sensitive Data from Entire Repository History

Accidentally committed API keys or passwords? Deleting the file in a new commit doesn’t remove it from history. Here’s how to purge it completely. ⚠️ The Problem: # You committed config.json with API key git add config.json git commit -m “Add config” git push # Then realized mistake and deleted it git rm config.json git […]

Read More
Git

Git: Undo Last Commit Without Losing Changes (3 Different Scenarios)

- 03.02.26 - ErcanOPAK comment on Git: Undo Last Commit Without Losing Changes (3 Different Scenarios)

Committed too early or to wrong branch? Here’s how to undo commits without losing your work, depending on whether you’ve pushed or not. Scenario 1: Undo Last Commit (Not Pushed Yet) # Keep changes in working directory (most common) git reset –soft HEAD~1 # Now your changes are uncommitted, ready to re-commit # Use case: […]

Read More
Git

Recover Deleted Git Commits Even After Hard Reset (It’s Not Gone)

- 01.02.26 | 01.02.26 - ErcanOPAK comment on Recover Deleted Git Commits Even After Hard Reset (It’s Not Gone)

Accidentally did ‘git reset –hard’ and lost hours of work? Your commits aren’t deleted – they’re just orphaned. Here’s how to find them. The Magic Command – Reflog: git reflog This shows every HEAD movement in your repository, even deleted commits. Output looks like: a1b2c3d HEAD@{0}: reset: moving to HEAD~3 e4f5g6h HEAD@{1}: commit: Added user […]

Read More
Git

The Hidden Cost of Large Commits (It’s Not Code Review)

- 31.01.26 - ErcanOPAK comment on The Hidden Cost of Large Commits (It’s Not Code Review)

Big commits don’t just slow reviews. Real damage Breaks git bisect Makes rollback risky Hides causal relationships Rule One commit = one reason. Mental model If you can’t describe the commit in one sentence, it’s too big.

Read More
Git

Stop Using git pull (Yes, Really)

- 29.01.26 - ErcanOPAK comment on Stop Using git pull (Yes, Really)

git pull = fetch + mergeYou lose control. Better git fetch git rebase origin/main Why Cleaner history Fewer merge commits Easier rollback Rule Explicit is safer than automatic.

Read More
February 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
232425262728  
« Jan    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (935)
  • How to add default value for Entity Framework migrations for DateTime and Bool (832)
  • Get the First and Last Word from a String or Sentence in SQL (826)
  • How to select distinct rows in a datatable in C# (799)
  • How to make theater mode the default for Youtube (717)
  • Add Constraint to SQL Table to ensure email contains @ (574)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (553)
  • Average of all values in a column that are not zero in SQL (520)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (474)
  • Find numbers with more than two decimal places in SQL (436)

Recent Posts

  • C#: Use MemoryPack for 10x Faster Serialization than JSON
  • C#: Use params ReadOnlySpan for Allocation-Free Variable Arguments
  • C#: Use ObjectPool for Reusing Expensive Objects
  • C#: Use Lazy for Expensive Object Initialization
  • SQL: Use STRING_AGG to Concatenate Rows into Comma-Separated List
  • SQL: Use Filtered Indexes to Index Only Subset of Rows
  • .NET Core: Use Result Pattern to Avoid Exceptions for Expected Errors
  • .NET Core: Use IOptions Pattern for Strongly-Typed Configuration
  • Git: Use .gitattributes to Handle Line Endings Across OS
  • Git: Use git notes to Add Comments to Commits Without Changing History

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (935)
  • How to add default value for Entity Framework migrations for DateTime and Bool (832)
  • Get the First and Last Word from a String or Sentence in SQL (826)
  • How to select distinct rows in a datatable in C# (799)
  • How to make theater mode the default for Youtube (717)

Recent Posts

  • C#: Use MemoryPack for 10x Faster Serialization than JSON
  • C#: Use params ReadOnlySpan for Allocation-Free Variable Arguments
  • C#: Use ObjectPool for Reusing Expensive Objects
  • C#: Use Lazy for Expensive Object Initialization
  • SQL: Use STRING_AGG to Concatenate Rows into Comma-Separated List

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com