🐙
Git Developer Guide
About
  • Overview
  • Scope of this book
  • Table of Content
  • 🐢Introduction to Version Control
    • What is Version Control?
    • Overview of git and it's benefits
    • Setting up Git on Different Platforms
  • 🍼Git Fundamentals
    • Initialising a new Git repository
    • Understanding the Git Workflow
    • Committing Changes and Writing Good Commit Messages
    • Viewing and Navigating Commit History
    • Git Basics - Practice Scenarios
      • Initialising a Git Repository
      • Committing Changes
      • Exploring Commit History
      • Amending and Undoing Commits
  • 🦕Working With Git
    • What is Git Branch?
    • Creating and Switching Between Branches
    • Merging Branches and Resolving Conflicts
    • Best Practices for Branch Management
    • Git Workflows
    • Git Log
    • Git Stash
    • Working with Git - Practice Scenarios
      • Creating and Switching Between Branches
      • Merging Branches and Resolving Conflicts
      • Branching Strategies in a Team Project
      • Rolling Back to a Previous Version
      • Experimenting with Feature Branches
      • Working with Stash
  • 🤝Working with Remote Repositories
    • Cloning a Repository from Remote
    • Pushing and Pulling Changes to and from Remote Repositories
    • Collaborative Workflows - Forking, Branching, and Pull Requests
    • Resolving Conflicts in a Collaborative Environment
    • Collaborating with Git - Practice Scenarios
      • Cloning a Remote Repository
      • Pushing and Pulling Changes
      • Collaborative Workflow with Forking and Pull Requests
      • Resolving Conflicts in a Pull Request
  • 🏆Advanced Git Features
    • Aliases and Custom Configurations
    • Working with Tags and Releases
    • Rewriting Commit History with Interactive Rebase
    • Utilising Git Hooks for Automation
    • Advanced Git Features - Practice Scenarios
      • Creating Custom Git Aliases
      • Working with Tags and Releases
      • Rewriting Commit History with Interactive Rebase
      • Using Git Hooks for Automated Testing
  • 😎Git in Real-World
    • Managing a Project with Multiple Contributors
    • Integrating Git with Continuous Integration, Continuous Deployment (CI, CD)
    • Versioning Assets with Git LFS (Large File Storage)
    • Deploying a Web Application using Git
    • Git In Real World - Practice Scenarios
      • Managing a Project with Multiple Contributors
      • Integrating Git with CICD Pipelines
      • Versioning Assets with Git LFS
      • Deploying a Web Application using Git
  • Git Troubleshooting
    • Common Mistakes and Pitfalls When Using Git
    • Undoing Changes with Git - Reverting and Resetting
    • Recovering Lost Commits or Branches
    • Dealing with Repository Corruption or Other Issues
  • Git Best Practices and Tips
    • Creating efficient git workflows: writing clean code for faster reviews
    • The importance of clean code in collaborative development
    • Significance of consistent naming conventions & coding Standards
    • Good code documentation for better git workflows
    • Writing meaningful git commit messages
    • Atomic commits in git & it's benefits for software teams
    • Structuring code & managing dependencies for better git workflows
    • Git branching strategies for software teams
  • Conclusion & Next Steps
    • Recap of Key Concepts and Commands
    • Further Resources for Expanding Git Knowledge
    • Encouragement and Tips for Continued Learning and Practice
  • License Considerations
Powered by GitBook
On this page

Was this helpful?

  1. Working With Git

Git Stash

Git stash provides a convenient way to save your work in progress and retrieve it later when needed.

In Git, "stash" refers to a feature that allows you to save changes that you have made to your working directory in a temporary area, separate from your commits and branches. The git stash command is used to stash or save these changes.

When working on a project, there might be situations where you want to switch to a different branch or perform other operations, but you're not ready to commit or lose the changes you've made in your working directory. This is where the git stash command comes in handy.

The git stash command takes the current state of your working directory (including both tracked and untracked changes) and saves it on a new "stash" stack. This stack allows you to save multiple stashes in chronological order, and you can apply or remove them later as needed. Stashes are stored independently of branches and commits.

Here are some common use cases and commands related to git stash:

Stashing changes

git stash

This command saves your working directory changes to a new stash entry. Git creates a clean working directory, reverting it to the state of the last commit.

Listing stashes

git stash list

This command lists all stashes in reverse chronological order. Each stash is identified by a unique identifier (e.g., stash@{0}) and provides information about the stash message, the branch where the stash was created, and the commit it was based on.

Applying a stash

git stash apply [stash_id]

This command applies the changes from the specified stash to your working directory. By default, the most recent stash is applied if no stash ID is provided. The stash remains in the stash stack after applying.

Applying and removing a stash

git stash pop [stash_id]

This command applies the changes from the specified stash and removes it from the stash stack. Similar to git stash apply, the most recent stash is popped if no stash ID is specified.

Viewing stash changes

git stash show [stash_id]

This command displays the changes made in the specified stash. It shows the file modifications and diff information.

Clearing stashes

git stash clear

This command removes all stashes from the stash stack.

Be cautious, as this action cannot be undone.

Using git stash is useful when you need to temporarily switch branches, pull changes from a remote repository, or perform other operations without committing your current changes.

PreviousGit LogNextWorking with Git - Practice Scenarios

Last updated 1 year ago

Was this helpful?

🦕