Just stashing away the changes is not enough. We can also view all the changes made to the files using the -p flag along with the Git Stash Show. By default, it displays the last stash but we can also pass the stash id to view some other stash information. This will display the files that were stashed and changes made to them. We can view the summary of a stash by using the show option. The highlighted part in the image shows the stash id. We can use the list option to view all the saved stashes. But we can still stash them by using the -u flag or the -include-untracked option. $ git stash save “Message”īy default, Git will not stash untracked files. This is useful if we are frequently stashing our changes from different branches. This helps us better understand what was stashed. We can add a message to our stashes by using the save option. Let’s take a look at some of the most important and useful options. The Git Stash command has several options to help us to stash and “un-stash” files. Even though we have the option to commit the changes but it is not a wise idea to commit some unfinished work and corrupt our committed history. Stashing is just a way of temporarily storing changes. When you come back to complete the feature you can just “un-stash” the changes and continue from where you left. You can just stash the changes and switch branches. But you are not done with the feature you are currently working on and don’t want to commit it yet. There may be scenarios where you are working on one feature of a project but want to apply changes to another feature on some other branch. What it means is that we can stash the changes we made in one branch and we can continue to work on those changes in some other branch by “un-stashing” in that branch. Stashing is also independent of branches. Our project is rolled back to the last committed state but we still have our work safely stashed away. Unstaged files are files that were added to the staging area at least once but have been modified. Untracked files are files that are newly created and not added to the staging area even once. But untracked files are not stashed by default and we need to specify if we want to stash these files. Stashing stores both staged and unstaged files. After stashing, all the changes that were not yet committed are temporarily stored. Stashing is the process of storing unsaved changes of our project in a separate location. We can come back to the stashed changes and continue our work from where we left it. It stores changes in our project in a safe place so that we can work on something else. This definition completely describes what Git Stash does. The meaning of the word stash is to safely store something in a hidden place.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |