1

I have this scenario:

Dev is my machine which I use to develop on, I created a git repo on it and commit to it regularly.

Staging is a server which I use to upload "stable" versions of my work to, I created a repo there too and added this server to the Dev remote repos

Whenever I want to push I simply use $ git push Staging master, this appears in the server immediately but in order to use the new code I need to do $ git reset --hard HEAD otherwise git thinks that I've edited the files on Staging and I don't have the "new" files.

I'm also not getting the part of Submodules in Git - I've tried a few techniques, mainly git submodule add https://github.com/documentcloud/underscore.git local/sub/dir/underscore, but I'm not getting any results except a dump of my current system $PATH value.

Help would be very appreciated! :)

Eli
  • 2,666
  • 7
  • 33
  • 37
  • 1
    This should be two questions, really, especially since the latter sounds rather bizarre - it could do with more details, including the exact command and output that you see. (Also the git version, your operating system and which shell you are using would be helpful.) – Mark Longair Oct 11 '11 at 12:26

3 Answers3

1

You shouldn't need submodule for that kind f setup, where you replicate one repo from one environment (Dev) to another (Staging), a bit like "git repository sync between computers, when moving around?".

Your process (add a remote and push) is correct, except you should:

  • push to a remote bare repo
  • have a post-receive hook able to update a separate working tree with the latest commi contents.

(Or you can directly fetch from the remote bare repo)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

About submodules, I suggest reading the relevant chapter of ProGit

p4010
  • 943
  • 7
  • 19
0

When you push to the remote repo, it does not automatically update the working copy on the staging server. By using the reset command, you update your working copy to the HEAD revision, which you have pushed before.

I think you can easy this setup with a hook on the server side which is executed after the push.

ZeissS
  • 11,867
  • 4
  • 35
  • 50