2

EDIT: I got my files back after cd .. and git checkout master.

Strange, it almost seems like this initialized a new repository inside the subfolder templates but I cannot see that I did a command like that. I still do not know what went wrong, here, though.

I've been using Git for about a month on my own projects, working very well.

However, today, I am not able to get back to my files. I honestly do not know why. I have done some commits, and then I wanted to checkout some earlier commits, so I did git checkout on a commit, and I got to that commit. Then I went a bit further back using the same command. I tried getting back to my most recent commit with git checkout master which for some reason did not work. I then tried git checkout head, thinking that was the command.

I then searched around and got some tips about a few other commands to run, which may have been bad advice. Glad this is only my own project.

I now feel sort of stuck, cannot really do much, and I am afraid to try anything more. Could you possibly help me?

I have included the ouputfrom terminal here, since my last commit, so you can see all the information. Sorry for pushing so much, but I honesly have no idea what went wrong.

➜  templates git:(hello_templates) ✗ gc
[hello_templates 258d27a] add rot13-page
 5 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 appengine/standard/templates/rot13.py
 create mode 100644 appengine/standard/templates/templates/rot13.html
➜  templates git:(hello_templates) ✗ gloh
zsh: command not found: gloh
➜  templates git:(hello_templates) glog
➜  templates git:(hello_templates) git checkout 615f292
Note: checking out '615f292'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 615f292... Crappy hard-coded bullshit
➜  templates git:(615f292) glg
➜  templates git:(615f292) glog
➜  templates git:(615f292) git checkout 076887a
Previous HEAD position was 615f292... Crappy hard-coded bullshit

HEAD is now at 076887a... Made form with validation, html-escaping and redirection
➜  templates git:(076887a) git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
➜  templates git:(master) gst
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working tree clean
➜  templates git:(master) git checkout head
Note: checking out 'head'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:


  git checkout -b <new-branch-name>

HEAD is now at 076887a... Made form with validation, html-escaping and redirection
➜  templates git:(076887a) glog
➜  templates git:(076887a) git checkout heada
error: pathspec 'heada' did not match any file(s) known to git.
➜  templates git:(076887a) git checkout head
HEAD is now at 076887a... Made form with validation, html-escaping and redirection
➜  templates git:(076887a) git branch
* (HEAD detached at head)
  hello_templates
  master
➜  templates git:(076887a) git checkout HEAD
➜  templates git:(076887a) git branch
* (HEAD detached at head)
  hello_templates
  master
➜  templates git:(076887a) gst
HEAD detached at head
nothing to commit, working tree clean
➜  templates git:(076887a) git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
➜  templates git:(master) git branch
  hello_templates
* master
➜  templates git:(master) glog
➜  templates git:(master) owd
zsh: command not found: owd
➜  templates git:(master) pwd
/Users/runarkristoffersen/dropbox/Data/cources/FullStack/googleapps/python-docs-samples/appengine/standard/templates
➜  templates git:(master) gco 615f292
error: pathspec '615f292' did not match any file(s) known to git.
➜  templates git:(master) ✗ git checkout HEAD^
error: pathspec 'HEAD^' did not match any file(s) known to git.
➜  templates git:(master) ✗ git checkout -
error: pathspec '-' did not match any file(s) known to git.
➜  templates git:(master) ✗ git reflog
fatal: your current branch 'master' does not have any commits yet
➜  templates git:(master) ✗ git checkout $(git log --branches -1 --pretty=format:"%H")
fatal: your current branch 'master' does not have any commits yet
fatal: You are on a branch yet to be born
➜  templates git:(master) ✗ gb
➜  templates git:(master) ✗ git branch
➜  templates git:(master) ✗ glog
fatal: your current branch 'master' does not have any commits yet
Runar
  • 245
  • 3
  • 17

1 Answers1

2

Strange, it almost seems like this initialized a new repository inside the subfolder templates but I cannot see that I did a command like that.

Either you did initialize a new repo (look for a templates/.git subfolder).

Or template was declared as a submodule. Look for a .gitmodules in one of the parent folders of template.

I found .git in the templates-folder

That would make the templates-folder a nested git repo, which would make its parent repo records only a gitlink (and not the folder content)

Removing the .git subfolder, and git add'ing the templates-folder is enough to get back on track.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I found `.git` in the templates-folder. no idea how it got there, I cannot see anything in my terminal history which would cause this. Maybe this question should just be closed as not broad enough. – Runar Mar 01 '17 at 10:09
  • @RunarTrollet no: you can accept the answer though (http://stackoverflow.com/help/accepted-answer) I have edited the answer. – VonC Mar 01 '17 at 10:14