无法让我的github分支"致命的错误工作树"

时间:2017-10-25 00:41:01

标签: git amazon-web-services github

对于这个项目,我远离两个实例(从家里)和使用PuTTY和SSH

$school =学校

$aws =亚马逊网络服务(运行Puppet的实例)

使用$school

创建的

git init --bare githubdir git

branches  config  description  HEAD  hooks  info  objects  refs
使用

创建

$aws git

Mkdir githubdir && cd githubdir
git init
git remote add origin studentID@$school:githubdir
  • 我需要从$school推送到运行Puppet的$aws来执行$school

  • 中的代码
  • 我需要从$school

  • 提交作品

我已成功从$school推送到$aws,但我想为版本控制设置分支,但是我在$school上遇到致命错误:

[studentID@$school githubdir]$ git status
fatal: This operation must be run in a work tree
[studentID@$school githubdir]$ git branch
* master
  v1
[studentID@$school githubdir]$ git checkout master
fatal: This operation must be run in a work tree
[studentID@$school githubdir]$
[studentID@$school githubdir]$ git log
commit  3abd0c361ee*********
Author: Ben*** <studentID@$school>
Date:   Date

    first commit to the repo test

我可以在$aws上分支/结帐等等:

[awsUser@$aws githubdir]$ git status
# On branch master
nothing to commit, working directory clean
[awsUser@$aws githubdir]$ git branch
* master
[awsUser@$aws githubdir]$ git checkout master
Already on 'master'
[awsUser@$aws githubdir]$ git log
commit  3abd0c361ee*********
Author: Ben*** <studentID@$school>
Date:   Date

    first commit to the repo test
[awsUser@$aws githubdir]$ ls
firstFile
[awsUser@$aws githubdir]$

我的理解不正确吗?我被指示以这种方式设置,但似乎我被告知要在$aws中写信并推送到$school

注意:您没有给我任何作业或分级类型问题的解决方案,这纯粹是我对环境和可能的执行流程的问题?

谢谢!

2 个答案:

答案 0 :(得分:1)

  

但似乎我被告知用$ aws写作并推送到$ school?

是的:您应该推送到 bare repo (即没有工作树的回购,没有实际文件)

这就是为什么你会看到像

这样的错误
[studentID@$school githubdir]$ git status
fatal: This operation must be run in a work tree

答案 1 :(得分:1)

enter image description here

这是一个简单的模型。 $school仅用于存储。 $aws仅用于制作,尽管可以在此处进行更改和提交。 $local用于开发。每个贡献者都可以拥有一个或多个本地存储库。

工作树是检出并放置文件的字段。对于生产和开发,您需要一个工作树,因此这些repoistories被创建为非裸存储库。对于存储,工作树不是必需的,裸存储库就足够了。有些命令需要工作树,例如git checkout,而其他命令则不需要git log