Managing a framework with Git, ignoring changes to given files after first pull

我怕爱的太早我们不能终老 提交于 2019-12-06 11:15:45
  • Files like config.php and database.php should never be committed back to the remote repo as they are unique to each site.

Put all the files that shouldn't be in the repo to the .gitignore file. That is hardly any vodoo, it's just a list of files that should be ignored.

  • However I want them to exist in the remote repo so on the first pull request the default files are downloaded to my local directory.

create dummy files like config.default.php and copy them after the first pull to the ignored name.

  • Further more if I do another pull from the remote repo to update the framework I do not want these files to be overwritten

done with the first to steps!

  1. Add config.php to your .gitignore.
  2. Create the default/distribution/base configuration to use, config.php-dist
  3. Create a Git hook, post-receive, like below.
  4. The hook will execute after each git pull, but the copy will only be done when config.php does not exist.

post-receive example (tailor to your needs):

#!/bin/bash
[ -f 'config.php' ] || cp config.php-dist config.php

I think what you want is a number of branches for each customised site and an extra upstream branch for the common files. It doesn't really make much difference where each branch lives (or if you've got multiple copies of it).

When you make a change to the common files, you can either make it directly on the common branch or create a checkin on one of the customised branches then cherry-pick it onto the common branch. You don't want to push changes to the common branch, because that will take the customisations as well as the fixes. It's safe to pull from the common branch to the customised branches, as any changes you've made will be merged in.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!