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
Git

Git: Use Stash to Temporarily Save Work-in-Progress

- 14.06.26 - ErcanOPAK

📦 Half-finished Feature? Switch Branch Without Committing

Can’t switch branches with uncommitted changes. git stash saves changes, cleans working directory, restores later.

📝 Basic Stash

# Save changes
git stash
git stash push -m "WIP: login feature"

# List stashes
git stash list
# stash@{0}: On main: WIP: login feature
# stash@{1}: On feature: half-done work

# Apply latest stash (keeps in stash)
git stash apply

# Apply specific stash
git stash apply stash@{1}

# Pop (apply and remove)
git stash pop

# See what's in stash
git stash show -p stash@{0}

# Create branch from stash
git stash branch new-branch stash@{0}

# Clear all stashes
git stash clear

🎯 Advanced Stash

# Stash untracked files
git stash -u

# Stash everything (including ignored)
git stash -a

# Stash only specific files
git stash push -m "partial" -- file1.txt file2.txt

# Stash without staging
git stash --keep-index

# Interactive stash
git stash save --patch

💡 Workflow

  • Start feature, make changes
  • Urgent bug fix needed → git stash
  • Switch branch, fix bug, commit, push
  • Switch back → git stash pop
  • Continue feature work

“Emergency fix needed while deep in feature. Stashed changes, fixed bug, popped stash. No commit mess. Git stash is essential for context switching.”

— Developer

Related posts:

Git: Use Git Push to Upload Local Commits to Remote

Git: Use Rebase for Clean Commit History

Git: Use git reflog to Recover Lost Commits After Reset

Post Views: 3

Post navigation

Ajax: JSON is Better Than XML — Here’s Why
.NET Core: Use Built-in ILogger for Structured Logging

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

July 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jun    

Most Viewed Posts

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

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes
  • Ajax: Use Axios for HTTP Requests
  • JavaScript: Understand Hoisting
  • HTML: Use Web Storage for Client-Side Data
  • CSS: Use Filter Effects for Visual Magic
  • Windows 11: Unlock God Mode for All Settings

Most Viewed Posts

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

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes

Social

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