Based on your comment, the problem is simply that you haven't yet initialized a git repository within your directory.
Git stores data and metadata within the .git
directory, stored in the top level of the git repository. If the repository has not yet been initialized, there is no "clean state" to which git stash
can revert the files. You'll need to create the repository, and then make a commit, and only then will you be able to stash subsequent changes.
As you seem to be fairly new to git, I'd strongly recommend staying away from 'stash' and keeping with commits to separate branches if you need to tuck your changes away somewhere. Stashes get messy, fast.
mkdir mygit || exit -1
cd mygit
git init
date > file.txt
git add file.txt
git commit -m 'My initial commit'
date >> file.txt
git status
git diff
git stash
git status
git diff
cd ..
rm -rf mygit
Here's an example, straight from the shell:
$ mkdir mygit || exit -1
$ cd mygit
$ git init
Initialized empty Git repository in /Users/dfarrell/mygit/.git/
$ date > file.txt
$ git add file.txt
$ git commit -m 'My initial commit'
[master (root-commit) 21de065] My initial commit
1 file changed, 1 insertion(+)
create mode 100644 file.txt
$ date >> file.txt
$ 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: file.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git diff
diff --git a/file.txt b/file.txt
index 99e9a80..8dcda34 100644
--- a/file.txt
+++ b/file.txt
@@ -1 +1,2 @@
Mon Dec 15 16:00:32 CST 2014
+Mon Dec 15 16:00:32 CST 2014
$ git stash
Saved working directory and index state WIP on master: 21de065 My initial commit
HEAD is now at 21de065 My initial commit
$ git status
On branch master
nothing to commit, working directory clean
$ git diff
$ cd ..
$ rm -rf mygit
$