MacWindowsSoftwareSettingsSecurityProductivityLinuxAndroidPerformanceConfigurationApple All

How to Stash Changes Using GitKraken

Edited 3 days ago by ExtremeHow Editorial Team

GitKrakenStashChangesGitVersion ControlRepositoryWorkflowCode ManagementSource CodeDevelopment

How to Stash Changes Using GitKraken

This content is available in 7 different language

GitKraken is a popular Git GUI (Graphical User Interface) client that makes managing Git repositories very easy. Out of the many features, one important function that GitKraken offers is the ability to store changes. Stashing allows you to save temporary changes to your working directory without adding a commit. This feature is especially helpful when you need to temporarily change context, yet want to preserve your current work for later use. This guide will tell you everything you need to know about storing changes in GitKraken.

Understanding Git stash

Stashing in Git is basically like setting aside a temporary work shelf. When you put unfinished changes into the stash, it's like storing them safely for later. You don't have to commit the changes to work on something else. Git will remove those changes from your working directory, but keep them on the stack so you can come back to them later.

The stash stack is independent of the branch you're working on; this means you can stash changes from one branch and apply them to another branch. You would typically interact with the stash using Git commands such as git stash, git stash list, and git stash apply. However, with GitKraken, you can perform these stashing actions more visually and interactively.

Why the change to stash?

The need to save changes arises when you encounter the following situations:

In such situations, saving the replacement money is essential as it helps you put your job on hold temporarily, and you can come back to it when you are ready to return to work.

Storing changes with GitKraken

Using GitKraken to archive changes is straightforward and user-friendly. The interface is designed in such a way that you can easily visualize the operations. The step-by-step process of archiving changes using GitKraken is as follows:

Step 1: Open your project

First, open GitKraken and navigate to your project or repository where you want to make changes. If you have already set up your repository in GitKraken, it should appear in the list of projects. Click on the project to open it.

Step 2: View the changes

After opening your project, click on the file tree view or the Commit panel where you will see all the changed files in your working directory. Uncommitted changes appear at the top under a section called Unstaged Changes. Here, you can see which files have been modified, added, or deleted.

Step 3: Put changes into the stash

To store changes, look for the Stash button in the Commit panel. Clicking this button will open a modal window or dropdown menu where you have the option to provide a descriptive message for your stored changes. Providing a descriptive message helps remember the purpose or context of your stored changes.

After writing the message, confirm the action to store the changes. At this point, GitKraken will delete the changes from your working directory and store them in the stash stack.

Step 4: Switching branches or context

Once your changes are stashed, you are free to switch to a different branch or pull changes from the remote without any conflicts. Use GitKraken's sidebar to navigate to another branch. Simply click on the branch you want to switch to. You will notice that your working directory will no longer contain the stashed changes.

Step 5: Apply stashed changes

When you're ready to return to your work, go back to the branch where you originally stored the changes (or to another branch if necessary). Open the Stash section located in the sidebar or top panel. Here, you'll see all the stashes you've created. Click on the desired stash entry, and it will reveal options such as Apply, Pop, and Delete.

Apply will merge the changes made in the stash into your current working directory without removing the stash from the list. Pop will apply the changes made in the stash and then remove the stash from the list. Choose the option that best suits your needs.

Example use case

Suppose you are working on a feature on feature-login branch. You have made changes to several files, but before you can commit your changes, a bug is reported on main branch that needs immediate attention. Here's how you would use stashing to handle this:

  1. Open your project in GitKraken and view your current changes in the Commit panel.
  2. Click the Stash button and provide a message for Stash like "Working on login feature". Confirm to stash your changes.
  3. Move to main branch to address the immediate bug.
  4. After resolving and committing the bug fix on main branch, switch back to feature-login.
  5. In the Stash section, find your stash message and apply or pop it to restore your work.

Conclusion

Using GitKraken is an efficient way to manage your temporary revisions to a project. The graphical interface makes it convenient to create, apply, and manage stashes without using the command line, which can be especially helpful if you prefer visual tools. As you become more comfortable with stashing, you'll appreciate the flexibility and productivity it can bring to your version control workflow.

Remember, you can always review the lists of stashes in GitKraken and choose the right time to apply them back to your working directory. Stashing is a powerful feature that makes Git a robust system for development, and using GitKraken makes it even more accessible.

If you find anything wrong with the article content, you can


Comments