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

Category: Git

Git

Git: Use Cherry-Pick to Apply Specific Commits Across Branches

- 30.03.26 - ErcanOPAK comment on Git: Use Cherry-Pick to Apply Specific Commits Across Branches

πŸ’ Pick Commits Like Cherries Need one commit from another branch? Don’t merge everything. Cherry-pick copies specific commits to your current branch. Surgical precision. The Problem # Scenario: Bug fix on wrong branch git branch * feature-login main hotfix # You committed bug fix to feature-login # But it needs to be on hotfix branch […]

Read More
Git

Git: Use Interactive Rebase to Clean Up Commit History Before Merge

- 30.03.26 - ErcanOPAK comment on Git: Use Interactive Rebase to Clean Up Commit History Before Merge

πŸ”§ Rewrite Git History 50 commits saying ‘fix typo’, ‘WIP’, ‘oops’? Messy history before PR? Interactive rebase lets you squash, reword, reorder commits. Clean history like a pro. The Messy History Problem git log –oneline a1b2c3d fix typo d4e5f6g WIP g7h8i9j oops forgot file j1k2l3m fix typo again m4n5o6p actually fix the bug p7q8r9s Add […]

Read More
Git

Git: Use git cherry-pick to Copy Specific Commits Between Branches

- 22.03.26 - ErcanOPAK comment on Git: Use git cherry-pick to Copy Specific Commits Between Branches

πŸ’ Pick Commits Like Cherries Need one commit from feature branch in production? Don’t merge entire branch. Cherry-pick that commit. The Scenario # Feature branch has 10 commits feature-branch: abc123 – Add user login def456 – Fix critical security bug ← Need this in production NOW ghi789 – Add dashboard … 7 more commits # […]

Read More
Git

Git: Use git stash to Save Work Without Committing

- 22.03.26 - ErcanOPAK comment on Git: Use git stash to Save Work Without Committing

πŸ’Ύ Save Work, Switch Branch, Come Back Halfway through feature. Emergency bug fix needed. Don’t want to commit messy code. git stash saves work temporarily. The Problem # Working on feature branch git status # modified: feature.js # modified: styles.css # Boss: “Fix production bug NOW!” git checkout main # Error: Your local changes would […]

Read More
Git

Git: Use git blame -L to Find Who Wrote Specific Lines

- 19.03.26 - ErcanOPAK comment on Git: Use git blame -L to Find Who Wrote Specific Lines

πŸ” Who Wrote This Code? Bug in production. Need to know who wrote line 247. git blame tells you author, date, commit. Basic Usage # Entire file git blame filename.js # Specific line range git blame -L 100,150 filename.js # Show line 247 only git blame -L 247,247 filename.js # Output: # abc12345 (John Doe […]

Read More
Git

Git: Use Interactive Rebase to Clean Up Commit History

- 19.03.26 - ErcanOPAK comment on Git: Use Interactive Rebase to Clean Up Commit History

✨ Rewrite Git History Like a Pro 10 messy commits saying ‘fix’, ‘oops’, ‘wtf’. Interactive rebase turns them into one clean, professional commit. Start Interactive Rebase # Rebase last 5 commits git rebase -i HEAD~5 # Or from specific commit git rebase -i abc1234 # Editor opens with commit list: pick abc1234 Add login feature […]

Read More
Git

Git: Use git cherry-pick to Copy Commits Between Branches

- 19.03.26 | 19.03.26 - ErcanOPAK comment on Git: Use git cherry-pick to Copy Commits Between Branches

Fixed bug in wrong branch. Need same fix in another branch. Don’t want to merge entire branch. # Switch to target branch git checkout main # Cherry-pick specific commit from other branch git cherry-pick abc1234 # Cherry-pick multiple commits git cherry-pick abc1234 def5678 ghi9012 # Cherry-pick range git cherry-pick abc1234..def5678 Conflicts: If conflict occurs, resolve […]

Read More
Git

Git: Use git stash -p to Stash Specific Changes

- 19.03.26 | 19.03.26 - ErcanOPAK comment on Git: Use git stash -p to Stash Specific Changes

Made 10 changes. Want to stash only 3. git stash takes everything. # Interactive stash (choose what to stash) git stash -p # Git asks for each change: # Stash this hunk? y/n/q/a/d/e y = yes, stash this n = no, keep this q = quit a = stash all remaining d = don’t stash […]

Read More
Git

Git: Use git reflog to Recover Deleted Commits

- 19.03.26 | 19.03.26 - ErcanOPAK comment on Git: Use git reflog to Recover Deleted Commits

πŸ’Ύ Git’s Time Machine Accidentally deleted branch? Reset to wrong commit? Reflog saves you. # View all HEAD movements (last 90 days) git reflog # Output shows: # abc1234 HEAD@{0}: reset: moving to HEAD~1 # def5678 HEAD@{1}: commit: Important work ← You want this! # Restore that commit git checkout def5678 git checkout -b recovery-branch […]

Read More
Git

Git: Use git bisect to Find Bug-Introducing Commit in Minutes

- 19.03.26 | 19.03.26 - ErcanOPAK comment on Git: Use git bisect to Find Bug-Introducing Commit in Minutes

πŸ” Binary Search for Bugs Bug appeared somewhere in last 100 commits. Which one? Bisect finds it in 7 tries (logβ‚‚ 100). git bisect start git bisect bad # Current commit has bug git bisect good abc1234 # This old commit was fine # Git checks out middle commit # You test: does bug exist? […]

Read More
Git

Git: Surgical Stashing – Don’t Save Everything!

- 01.03.26 - ErcanOPAK comment on Git: Surgical Stashing – Don’t Save Everything!

Sometimes you only want to temporarily hide one file, not your whole workspace. Use git stash push. git stash push -m “temporary fix” path/to/file.js This keeps your other experimental changes active while you fix a bug in a specific file. Total workflow control.

Read More
Git

Git: Writing Commits That Your Future Self Won’t Hate

- 01.03.26 - ErcanOPAK comment on Git: Writing Commits That Your Future Self Won’t Hate

# Bad: fix bug # Good: feat(auth): add password strength validation Follow the Conventional Commits standard. It makes your history searchable and allows for automated changelog generation.

Read More
Git

Git: Automating Code Quality with Client-Side Git Hooks

- 01.03.26 - ErcanOPAK comment on Git: Automating Code Quality with Client-Side Git Hooks

Prevent broken code from even reaching the server. Use a pre-commit hook to run linter and unit tests locally. By placing a script in .git/hooks/pre-commit, you ensure that if tests fail, the commit is blocked. This creates a ‘Quality First’ culture in the development team.

Read More
Git

Git: Recovering ‘Lost’ Commits with the Power of Reflog

- 01.03.26 - ErcanOPAK comment on Git: Recovering ‘Lost’ Commits with the Power of Reflog

Did you git reset –hard and lose your work? Don’t panic. Git almost never deletes anything immediately. Reflog tracks every move of the HEAD. git reflog # Find the hash before the mistake git reset –hard [HASH] This is the ‘Undo’ button for your entire Git history. It’s the difference between a productive day and […]

Read More
Git

Git: Ignoring Local Changes to Tracked Files (Config Protection)

- 01.03.26 - ErcanOPAK comment on Git: Ignoring Local Changes to Tracked Files (Config Protection)

Have a local appsettings.json you don’t want to commit, but it’s already tracked? Don’t use .gitignore; use assume-unchanged. git update-index –assume-unchanged config.json Now Git will pretend there are no changes to that file, even if you edit it locally. Perfect for local dev secrets.

Read More
Git

Git: Surgical History Edits with Interactive Rebase (fixup)

- 01.03.26 - ErcanOPAK comment on Git: Surgical History Edits with Interactive Rebase (fixup)

Interactive rebase is the ‘Photoshop’ of Git history. Use fixup to merge a tiny fix into a previous commit without a trace. git rebase -i HEAD~5 # Change ‘pick’ to ‘fixup’ for your small typo fixes. This results in a clean, linear history where every commit is a meaningful, working feature.

Read More
Git

Git: Applying a Specific Fix from One Branch to Another with Cherry-Pick

- 28.02.26 - ErcanOPAK comment on Git: Applying a Specific Fix from One Branch to Another with Cherry-Pick

You fixed a critical bug in the experimental branch, but you aren’t ready to merge the whole branch to production yet. Use Cherry-Pick. git cherry-pick [COMMIT_HASH] This copies only that specific commit’s changes and applies them to your current branch. Surgical and clean.

Read More
Git

Git: Finding the Exact Commit That Broke Your App with Bisect

- 28.02.26 - ErcanOPAK comment on Git: Finding the Exact Commit That Broke Your App with Bisect

The code was working 2 weeks ago, and now it’s broken. You have 200 commits to check. Don’t do it manually. git bisect start git bisect bad # Current version is broken git bisect good abc123 # This commit was working Git will use binary search to narrow down the culprit in just a few […]

Read More
Git

Git: Cleaning Up Your Branch History with Squash and Merge

- 28.02.26 - ErcanOPAK comment on Git: Cleaning Up Your Branch History with Squash and Merge

Nobody needs to see your ‘oops’, ‘fix typo’, and ‘test’ commits in the main history. Use Squash. When merging a feature branch, it combines all 20 of your messy commits into one single, clean commit. This keeps the production history readable and professional.

Read More
Git

Git: Saving Hours of Typing with Custom Git Aliases

- 28.02.26 - ErcanOPAK comment on Git: Saving Hours of Typing with Custom Git Aliases

Stop typing git checkout and git commit. Create professional shortcuts in your .gitconfig. git config –global alias.co checkout git config –global alias.br branch git config –global alias.st status git config –global alias.last ‘log -1 HEAD’ Now, git st does exactly what git status does. Small change, massive daily time savings.

Read More
Git

Git: Switching Branches Without Committing Half-Done Work

- 28.02.26 - ErcanOPAK comment on Git: Switching Branches Without Committing Half-Done Work

Your boss wants a quick fix on ‘Main’, but your ‘Feature’ branch is a mess. Use Stash. git stash # Save work to a temporary pile git checkout main # Switch and do the fix git checkout dev # Switch back git stash pop # Bring work back

Read More
Git

Git: How to Fix a Typo in Your Last Commit Message

- 28.02.26 - ErcanOPAK comment on Git: How to Fix a Typo in Your Last Commit Message

Made a typo in your commit? Don’t delete and start over. Use Amend. git commit –amend -m “Your corrected message” Warning: Only use this for commits that haven’t been pushed to a shared repository yet!

Read More
Git

Git Worktrees: Work on Multiple Branches Simultaneously Without Stashing

- 23.02.26 | 23.02.26 - ErcanOPAK comment on Git Worktrees: Work on Multiple Branches Simultaneously Without Stashing

πŸ”€ The Context Switch Nightmare You’re deep in feature work. Urgent bug reported. You stash, switch branches, fix bug, switch back, pop stash… 20 minutes lost. Your flow? Destroyed. Git Worktrees: Multiple Working Directories, One Repo ❌ The Old Way (Painful) # Working on feature branch $ git status On branch feature/new-dashboard Changes not staged… […]

Read More
Git

Git: Use git commit –amend to Fix Last Commit Without New Commit

- 22.02.26 | 22.02.26 - ErcanOPAK comment on Git: Use git commit –amend to Fix Last Commit Without New Commit

Forgot to add file or typo in commit message? –amend fixes last commit without creating new one. Fix Commit Message: git commit –amend -m “Corrected message” Add Forgotten Files: git add forgotten_file.js git commit –amend –no-edit # Add to last commit, keep message ⚠️ Warning: Never amend commits that are already pushed! Rewrites history = […]

Read More
Git

Git: Use git diff –staged to Review Changes Before Commit

- 22.02.26 | 22.02.26 - ErcanOPAK comment on Git: Use git diff –staged to Review Changes Before Commit

Committing without review leads to mistakes. –staged shows exactly what will be committed. See Staged Changes: git diff –staged # Shows changes that are staged (git add-ed) for commit vs git diff: git diff (no flags) shows unstaged changes only. –staged shows what’s going into the commit. Review Workflow: git add . git diff –staged […]

Read More
Git

Git: Mastering Worktrees to Handle Multiple Tasks Simultaneously

- 21.02.26 - ErcanOPAK comment on Git: Mastering Worktrees to Handle Multiple Tasks Simultaneously

Stop stashing! git worktree lets you have multiple branches of the same repo checked out in different folders at the same time. You can fix a bug on ‘prod’ without touching your work-in-progress on ‘dev’.

Read More
Git

Git: The Ultimate Safety Net – Recovering ‘Deleted’ Work with Reflog

- 21.02.26 - ErcanOPAK comment on Git: The Ultimate Safety Net – Recovering ‘Deleted’ Work with Reflog

Did you accidentally delete a branch? Or lose a commit during a bad rebase? git reflog is your time machine. It records every single movement of the HEAD, even those not in the history.

Read More
Git

Git: Managing Multiple GitHub Accounts with SSH Config

- 21.02.26 - ErcanOPAK comment on Git: Managing Multiple GitHub Accounts with SSH Config

Stop using HTTPS and typing passwords. Use an ~/.ssh/config file to manage work and personal Git accounts seamlessly on one machine.

Read More
Git

Git: Cleaning Up Your Commit Mess with ‘Interactive Rebase’

- 21.02.26 - ErcanOPAK comment on Git: Cleaning Up Your Commit Mess with ‘Interactive Rebase’

Professionals never push ‘fix typo’ commits. They clean their history first. git rebase -i HEAD~5 This opens an editor where you can squash multiple commits into one clean, professional summary. Your senior dev will love you.

Read More
Git

Git: Find the Exact Commit that Broke Your Code with Bisect

- 21.02.26 - ErcanOPAK comment on Git: Find the Exact Commit that Broke Your Code with Bisect

When a bug appears and you don’t know when it started, use Git Bisect. It uses binary search to find the faulty commit in seconds.

Read More
Page 1 of 4
1 2 3 4 Next Β»

Posts navigation

Older posts
April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

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

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

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

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

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