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

Tag: Git Tips

Git

Git: Use git restore to Unstage Files Without Losing Changes

- 13.02.26 - ErcanOPAK comment on Git: Use git restore to Unstage Files Without Losing Changes

Accidentally staged files you didn’t mean to commit? git restore unstages them without deleting changes. Unstage Specific File: # Staged config.json by mistake git add config.json # Unstage it (keeps changes in working directory) git restore –staged config.json Unstage All Files: git restore –staged . Discard Changes (Careful!): # Unstage AND discard changes git restore […]

Read More
Git

Git: Use git bisect to Find Which Commit Introduced a Bug

- 13.02.26 - ErcanOPAK comment on Git: Use git bisect to Find Which Commit Introduced a Bug

Bug appeared somewhere in last 100 commits but don’t know where? Git bisect does binary search to find the exact commit. Start Bisect: # Mark current commit as bad git bisect start git bisect bad # Mark last known good commit (e.g., a week ago) git bisect good abc1234 Git Checks Out Middle Commit: # […]

Read More
Git

Git: Stash Untracked Files with –include-untracked Flag

- 13.02.26 - ErcanOPAK comment on Git: Stash Untracked Files with –include-untracked Flag

Regular git stash only saves tracked files. New files you created get left behind. Include Untracked Files: git stash –include-untracked # Or shorthand: git stash -u Now new files are stashed too! Apply Later: git stash pop Stash Everything (Including Ignored Files): git stash –all Useful before git clean or switching branches with incomplete work.

Read More
Git

Git: Create Aliases for Common Commands to Save Typing

- 13.02.26 - ErcanOPAK comment on Git: Create Aliases for Common Commands to Save Typing

Tired of typing git status, git commit -am, git log –oneline? Create short aliases. Setup: git config –global alias.st status git config –global alias.co checkout git config –global alias.br branch git config –global alias.cm ‘commit -m’ git config –global alias.lg ‘log –oneline –graph –all’ Now Use: git st # Instead of: git status git co […]

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: 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

Speed Up Git Operations 10x by Cleaning Up Bloated Repository History

- 01.02.26 | 01.02.26 - ErcanOPAK comment on Speed Up Git Operations 10x by Cleaning Up Bloated Repository History

Is ‘git clone’ taking 10 minutes? Your repository probably has bloated history from large files that were deleted years ago but still exist in Git’s object database. Diagnose the Problem: # Check repository size du -sh .git # If this is >500MB for a code project, you have bloat # Find largest objects in Git […]

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
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 (934)
  • How to add default value for Entity Framework migrations for DateTime and Bool (830)
  • Get the First and Last Word from a String or Sentence in SQL (822)
  • How to select distinct rows in a datatable in C# (799)
  • How to make theater mode the default for Youtube (708)
  • Add Constraint to SQL Table to ensure email contains @ (572)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (552)
  • Average of all values in a column that are not zero in SQL (517)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (473)
  • Find numbers with more than two decimal places in SQL (436)

Recent Posts

  • C#: Use init Accessor to Create Immutable Objects Without Constructor Boilerplate
  • C#: Use Index and Range Operators for Cleaner Array Slicing
  • C#: Use Null-Coalescing Assignment to Simplify Lazy Initialization
  • SQL: Use CHAR Instead of VARCHAR for Fixed-Length Columns to Save Space
  • SQL: Use CROSS APPLY Instead of Subqueries for Better Performance
  • .NET Core: Use Required Modifier to Force Property Initialization
  • .NET Core: Use Global Using Directives to Avoid Repeating Imports
  • Git: Use git restore to Unstage Files Without Losing Changes
  • Git: Use git bisect to Find Which Commit Introduced a Bug
  • AJAX: Use Fetch with Signal to Cancel Requests When User Navigates Away

Most Viewed Posts

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

Recent Posts

  • C#: Use init Accessor to Create Immutable Objects Without Constructor Boilerplate
  • C#: Use Index and Range Operators for Cleaner Array Slicing
  • C#: Use Null-Coalescing Assignment to Simplify Lazy Initialization
  • SQL: Use CHAR Instead of VARCHAR for Fixed-Length Columns to Save Space
  • SQL: Use CROSS APPLY Instead of Subqueries for Better Performance

Social

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