简体   繁体   English

使用Bitbucket开发网站的Git模型

[英]Git model for website development with Bitbucket

I have been reading up on Git lately a lot and now I have tried to incorporate all of that stuff into my workflow. 最近,我一直在阅读有关Git的文章,现在我尝试将所有这些内容纳入我的工作流程。 Basically everything is working but I have a weired behaviour which I can't explain nor get my head around it really. 基本上所有的东西都在工作,但是我有一个奇怪的行为,我无法解释也无法真正解决。 I have searched the internet up and down for this problem but since Git give's you so much freedom to which moving parts to use or to not use I find it hard to find an answer to my specific situation. 我已经在互联网上上下搜索了这个问题,但是由于Git为您提供了使用或不使用运动部件的极大自由度,因此很难找到适合我的具体情况的答案。

So, here is my setup/my steps that I have accomplished so far: 因此,这是我到目前为止已完成的设置/步骤:

  • In the beginning I had an already running website (running EE as CMS). 最初,我有一个已经运行的网站(将EE作为CMS运行)。 I'll refer to this as PROD. 我将其称为PROD。 I reconfigured some files and paths and stuff to make everything flexible to have this instance running on different servers/enviroments via config files, relative paths and so on 我重新配置了一些文件,路径和内容,以使一切变得灵活,以使该实例通过配置文件,相对路径等在不同的服务器/环境上运行
  • Then I added .gitignore file and configured to my needs (eg. excluding cache folders) 然后,我添加了.gitignore文件,并根据需要进行了配置(例如,不包括缓存文件夹)
  • Initialized git 初始化git
  • Pushed this repo to Bitbucket (I'll refer this as BB). 将此回购推送到Bitbucket(我将其称为BB)。
  • Cloned the repo to local. 将回购克隆到本地。 I'll refer to this as DEV. 我将其称为DEV。
  • Then I configured the service FTPloy to handle deploys whenever I push from DEV to BB. 然后,我将服务FTPloy配置为在我从DEV推送到BB时处理部署。
  • Then I made changes to two files in DEV 然后我对DEV中的两个文件进行了更改
  • Commited the changes and pushed to BB 提交更改并推送到BB
  • Those changes are then also reflected on PROD 这些更改也将反映在PROD上

So, all fine until here. 所以,一切都很好,直到这里。 Now comes the weird part/the part I don't get: 现在出现了奇怪的部分/我没有得到的部分:

When I ssh into PROD after doing the above steps and running "git status" I get this: 在完成上述步骤并运行“ git status”后,我将其SSH到PROD中时,我得到了:

# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   public_html/assets/templates/default_site/blog.group/_entry.html
#   modified:   public_html/assets/templates/default_site/blog.group/index.html

Those two modified files are the ones I just pushed from DEV so it seems kinda logical to me but then again at the same time totally not. 那两个修改过的文件是我刚刚从DEV推送的文件,因此对我来说似乎有点合逻辑,但同时又完全不是。 It seems like I created an endless loop or something. 好像我创建了一个无尽的循环之类的东西。

Does anybody spot the mistake that I have made in my setup or knows how to fix this? 是否有人发现我在设置中犯的错误或知道如何解决?

Thanks! 谢谢!

Could it be that you did not use "git add" after modifying your files ? 修改文件后,您可能没有使用“ git add”吗? In contrast with other cvs's if you modify a file it isn't staged. 与其他cvs相比,如果您修改文件,则不会暂存文件。 The work flow would be to edit a file, use git add to stage it, git commit and then push. 工作流程是编辑文件,使用git add暂存文件,git commit然后推送。 Otherwise your changes won't be pushed. 否则,您的更改将不会被推送。 You could also check it in your dev env if you run there "git status" 您也可以在开发环境中运行“ git status”来检查它

See Git Pro Book 参阅Git Pro书

I ended up contacting FTPloy as I assumed that my problem might have something to do with the way FTPloy works. 我最终联系FTPloy,因为我认为我的问题可能与FTPloy的工作方式有关。 Here is what they said: 他们说的是:

Git shouldn't be initialised on your server if you're deploying with FTPloy as we don't have access to the .git directory on Bitbucket and only deploy your actual code. 如果您使用FTPloy进行部署,则不应在服务器上初始化Git,因为我们无权访问Bitbucket上的.git目录,而只能部署您的实际代码。 There are numerous security risks with deploying the .git directory so I won't get into those now. 部署.git目录存在很多安全隐患,因此我现在不再赘述。

So, I'll remove the .git folder from my Production server and rsync Assets like user uploaded images to my local repo once in a while. 因此,我会不时从生产服务器中删除.git文件夹,并像用户将图像上传到本地存储库一样重新同步资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM