![]() ![]() git stash drop you got some useful tricks about Git stash. But use it with caution, it maybe be difficult to revert. This command deletes the latest stash from the stack. This command deletes all the stashes made in the repo. git stash branch will be useful when you run into conflicts after you’ve applied the stash to the latest version of your branch. If you need a particular stash you can specify the stash id. This command creates a new branch with the latest stash, and then deletes the latest stash ( like stash pop). Likewise with other commands, you can also specify the stash id to get the diff summary. If you want to see the full diff, you can use git stash show -p Here’s the example: Git stash show example The above command considers only the latest stash. This command shows the summary of the stash diffs. Likewise, if you want a particular stash to pop you can specify the stash id. Here’s the example: Git stash pop exampleĪs you can see the top stash is deleted and is updated with older stash. This command is very similar to stash apply but it deletes the stash from the stack after it is applied. Here’s the example: git stash apply Git stash pop In our case it is you want to apply some other stash you can specify the stash id. This command takes the top most stash in the stack and applies it to the repo. And the most recent stash made is in the top.Īnd you can see that the top stash is given a custom message (using Git stash save “message” ). See the example below: git stash list example So it means that you can view the list of stashes you made at any time. When you Git stash or Git stash save, Git will actually create a Git commit object with some name and then save it in your repo. Git stash save -include-untracked Git stash listīefore discussing this command, let me tell you something about how stash works. We will see how this is helpful in a bit. The above command stashes with a message. Git stash with message git stash save “Your stash message”. I will discuss some important options in this post. But this command comes with various options. Here are some of the useful tricks I learned about Git stash last week. If you have been using Git for a while you might have used Git stash. If you are interested in getting your game better in Git, you should definitely check that out. If you want to show the actual date, rather than a relative time then replace %(cr) with %(ci).I have launched a newsletter Git Better to help learn new tricks and advanced topics of Git. (You can see that I also have similar markups for log and reflog) Sl = stash list -pretty=format:\"%C(red)%h%C(reset) - %C(dim yellow)(%C(bold magenta)%gd%C(dim yellow))%C(reset) %%C(reset)\" Rl = reflog -pretty=format:\"%Cred%h%Creset %C(auto)%gd%Creset %C(auto)%gs%C(reset) %C(green)(%cr)%C(reset) %C(bold blue)%Creset\" -abbrev-commit Lg = log -graph -pretty=format:\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset\" -abbrev-commit I have this set in the section of my ~/.gitconfig file, so that I can bind it to a simple sl command: For example, this produces a stash list that includes a relative time: git stash list -pretty=format:"%C(red)%h%C(reset) - %C(dim yellow)(%C(bold magenta)%gd%C(dim yellow))%C(reset) %%C(reset)" You can use -pretty=format to achieve this. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |