0

For this project I am remote from both instances (from home)and using PuTTY with SSH

$school = School

$aws = Amazon web service (instance running Puppet)

$school git created using git init --bare githubdir

branches  config  description  HEAD  hooks  info  objects  refs

$aws git created using

Mkdir githubdir && cd githubdir
git init
git remote add origin studentID@$school:githubdir
  • I need to push from $school to $aws that is running Puppet to execute code from $school

  • I need to submit work from $school

I have successfully pushed from $school to $aws but I wanted to setup branches for version control, however I get fatal error on $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

I can branch/checkout etc fine on $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]$

Have I got my understanding incorrect of flow? I was instructed to set up this way, but it seems that I have been told to write in $aws and push to $school?

Note: You are not giving me a solution to any assignment or graded type questions, this is purely an issues I am having with the environment and possibly the flow of execution?

Thanks!

Ben
  • 295
  • 5
  • 19

2 Answers2

1

but it seems that I have been told to write in $aws and push to $school?

Yes: you are supposed to push to a bare repo (ie a repo without a working tree, without the actual files)

That is why you see errors like

[studentID@$school githubdir]$ git status
fatal: This operation must be run in a work tree
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

enter image description here

Here's a simple model. $school is for storage only. $aws is for production only although it's possible to make changes and commits here. $local is for development. Every contributor can have one or more local repositories.

A work tree is a field where files are checked out and placed. For production and development you need a work tree, so these repoistories are created as non-bare repositories. For storage, the work tree is not necessary and a bare repository is enough. Some commands need a work tree, like git checkout, and others don't, like git log.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53
  • Thank you for the detailed model, it helped me visualize it a lot better than a lot of the written documents! – Ben Oct 25 '17 at 05:22