Using git, I am working on the master branch and have a few unadded and uncommitted files. I don't want to add them or commit them to the master. Instead, I am trying to stash the files and move to a new branch to add them and commit them there. However, this is failing with the error message: "No stash found.". Please see the log below:
$git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Makefile
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# newfile.c
no changes added to commit (use "git add" and/or "git commit -a")
And then when I try to use git stash
$git stash branch mywork
No stash found.
I am pretty sure the I used git stash in a similar manner before, but I can't see why it is failing now. How can I stash my changes to another branch and commit them there?
The git stash branch
command creates a new branch from an already existing stash. Because you don't have an existing stash yet, you get the error message.
Just use git stash
and after that, if you want to create a new branch from this stash, git stash branch mywork
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With