TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • TestNG
  • Tools
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Git

Stash Changes it Git

Git Tutorials

Introduction

In this tutorial, we will know the steps involved to stash changes in the Git source control tool. We can stash local changes to store in a safe place using Git. Stashing a change removes the change and stores it so that we can apply later or delete the changes. The local changes will need to be committed to the remote GitHub repository.

Let’s run some commands to get a better understanding. Let’s create a file and then we stash it.

// We will stash this change and file
public class StashingChanges {

 public static void main(String[] args) {
 // TODO Auto-generated method stub
 System.out.println("Stashed File...");
 }

}

 

git Stash

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (master)
$ git stash
No local changes to save

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (master)
$ git add ^C

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (master)
$ git add src/StashingChanges.java

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (master)
$ git stash
Saved working directory and index state WIP on master: ea95ebc 
Merge pull request #3 from yskumar007/git-branch-demo

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

 

 

 

Git stashing changes

Git stash List

To see which stashes we have stashed, we can use

$ git stash list

If we want to apply all the stashes we can use the apply command

$ git stash apply

 

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (master)
$ git stash list
stash@{0}: WIP on master: ea95ebc Merge pull request #3 from 
yskumar007/git-branch-demo

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (master)
$ git stash apply
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
 (use "git restore --staged <file>..." to unstage)
 new file: src/StashingChanges.java

 

Git Tutorial on this website can be found at:

https://www.testingdocs.com/git-tutorials/

For more details on the Git, visit the official website at:

https://git-scm.com

Related Posts

branching

Git /

What is Branching?

Git Install on Linux

Git /

Install Git on Ubuntu Linux

Version_Control_Centralized

Git /

Overview of Version Control Systems

Git Website

Git /

Getting Started with Git Version Control

Install Git on Windows 10

Git /

Install Git on Windows 10

‹ Git Basic Interview Questions› Resolve merge conflicts on GitHub

Recent Posts

  • Antivirus Products for Windows 11 PC
  • Install CodeBlocks IDE on Windows 11
  • Location Privacy Settings on Windows
  • Windows 11 Virus & Threat Protection
  • Download & Install Python on Windows 11
  • Cumulative Update for Windows 11 Version
  • Test execution speed in Selenium IDE
  • Check Windows 11 Free Upgrade
  • Download IntelliJ IDE on Windows 11
  • New MySQL Connection in Workbench

Back to Top

Automation Tutorials

  • JBehave Tutorial
  • Selenium Tutorial
  • TestNG Tutorial
  • JUnit Tutorial

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version