DEV Community

San
San

Posted on

Git stash cmd

1. Git stash command list
Git stash with auto random name given by git:

git stash
Enter fullscreen mode Exit fullscreen mode

Git stash with name - keep file without commiting code and push locally.

git stash -m "old code"
Enter fullscreen mode Exit fullscreen mode

Check changes list in stash

git stash list
Enter fullscreen mode Exit fullscreen mode

Apply stash changes: git stash apply :- its apply the latest stash changes.

Apply specefic changes according to stash list

git stash apply stash@{0}
Enter fullscreen mode Exit fullscreen mode

Delete latest stash: it delete the latest (last) form stash list.

git stash pop
Enter fullscreen mode Exit fullscreen mode

Delete particular stash: it delete the particular stash from list

git stash drop stash@{1}
Enter fullscreen mode Exit fullscreen mode

Delete all stash

git stash clear
Enter fullscreen mode Exit fullscreen mode

Create new stash branch with existing stash list. Its also delete the stash@{0}.

git stash branch "branch_name" stash@{0}
Enter fullscreen mode Exit fullscreen mode
  1. Check remote url: to see the current remote URL.
git remote -v
Enter fullscreen mode Exit fullscreen mode

How to know the git username and email saved

To know the username, type:

git config user.name
Enter fullscreen mode Exit fullscreen mode

To know the email, type:

git config user.email
Enter fullscreen mode Exit fullscreen mode

Configuring Git username and email.

git config --global user.name "My Name"
Enter fullscreen mode Exit fullscreen mode
git config --global user.email "myemail@example.com"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)