2017-02-28 30 views
2

编辑:我有我的文件cd ..git checkout master后回来。不能回到我最近提交(或其中的任何)

奇怪的是,它几乎看起来像这样初始化子文件夹templates内的一个新的存储库,但我看不到我做了这样的命令。尽管如此,我仍然不知道哪里出了问题。

我一直在我自己的项目上使用Git大约一个月,工作得很好。

但是,今天,我无法回到我的文件。我真的不知道为什么。我已经做了一些提交,然后我想结账一些早期的提交,所以我做了一个提交git checkout,并且我完成了提交。然后我使用相同的命令进一步回去。我试图回到我最近的提交git checkout master,由于某种原因没有工作。然后我试着git checkout head,认为这是命令。

然后我搜索了一些关于其他几个命令的提示,这些提示可能是不好的建议。很高兴这只是我自己的项目。

我现在觉得有点卡住了,真的不能做太多,我害怕再试一次。你能帮我吗?

自从我上次提交以来,我在这里包含了来自终端的输出,因此您可以看到所有信息。对不起推这么多,但我真的不知道出了什么问题。

➜ 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 

回答

2

陌生,它似乎像这样初始化里面的子文件夹模板创建一个新库,但我看不到,我做了一个这样的命令。

您可以初始化一个新的回购(查找templates/.git子文件夹)。

或模板被声明为submodule。查找template的父文件夹之一.gitmodules in

我在templates-folder

发现.git这将使templates-folder嵌套混帐回购协议,这将使得其母公司回购的记录只有gitlink(而不是文件夹中的内容)

删除.git子文件夹和git addtemplates-folder”就足以恢复正常。

+0

我在模板文件夹中找到'.git'。不知道它是如何到达那里的,我在终端历史中看不到任何会导致这种情况的东西。也许这个问题应该被封闭得不够广泛。 – Runar

+0

@RunarTrollet否:你可以接受答案虽然(http://stackoverflow.com/help/accepted-answer)我已经编辑了答案。 – VonC

相关问题