开发者

Something I don't get about Git - Pushing and Pulling and Nested Repositories

开发者 https://www.devze.com 2023-04-11 23:32 出处:网络
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.

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! :)


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)


About submodules, I suggest reading the relevant chapter of ProGit


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消