使用Git管理框架,忽略第一次拉动后给定文件的更改 [英] Managing a framework with Git, ignoring changes to given files after first pull

查看:101
本文介绍了使用Git管理框架,忽略第一次拉动后给定文件的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用git来管理扩展的CodeIgniter框架。它是当前CI版本的一个克隆,包含额外的帮助器,库等。



我有许多站点都使用这个框架,如果我添加一个新的辅助方法或修复一个bug在一个站点中,我希望能够轻松更新所有其他站点,而不会覆盖任何自定义文件。



我希望实现以下工作流程


  1. 创建一个新的站点目录 git init 来初始化一个空的本地git repo

  2. 将此链接与远程框架repo git remote add origin git@github.com:username / framework_repo

  3. 一个新的远程框架副本 git pull origin master

  4. 更改站点文件并将它们提交回远程仓库 git push origin master

  5. 将这些更改提交到其他网站

  6. 重复步骤4& 5

这就好,但::


  • 像config.php和database.php这样的文件不应该被提交回远程仓库,因为它们对于每个站点都是唯一的。

  • 但是我希望它们存在于远程仓库中在第一次请求时,默认文件会被下载到我的本地目录中。

  • 更进一步,如果我从远程仓库再次执行更新以更新框架,我不希望这些文件被覆盖



达到此目的的最佳方法是什么?一些.gitignore伏都教?
我已经使用.gitignore忽略文件,但在这种情况下,它略有不同,因为我只想在第一次请求时拉取文件。



我希望这就说得通了。

解决方案



  • 像config.php和database.php这样的文件永远不应该将
    返还给远程仓库,因为它们是每个站点唯一的


将所有不应该在repo中的文件放到 .gitignore 文件中。



  • 但是我想要它们存在于远程仓库中,所以在第一次拉
    请求时,默认文件是
    下载到我的本地目录中。

创建像 config.default.php 这样的虚拟文件,并在第一次拉动后将它们复制到忽略的名称。



  • 更进一步,如果我从远程repo更新
    框架,我不希望这些文件
    被覆盖


完成第一步!


I'm using git to manage an extended CodeIgniter Framework. It's a clone of the current CI release with extra helpers, libraries ect.

I have many sites all using this framework and if I add a new helper method or fix a bug in one site I want to be able to easily update all the other sites without overwriting any of their custom files.

I wish to achieve the following workflow

  1. Create a new site directory git init to initialise a blank local git repo
  2. Link this with the remote framework repo git remote add origin git@github.com:username/framework_repo
  3. Pull a fresh copy of the remote framework git pull origin master
  4. Make changes to site files and commit them back to the remote repo git push origin master
  5. Pull these changes down to the other sites
  6. Repeat steps 4 & 5

Thats all fine, BUT:

  • Files like config.php and database.php should never be committed back to the remote repo as they are unique to each site.
  • 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.
  • Further more if I do another pull from the remote repo to update the framework I do not want these files to be overwritten

Whats the best way to achieve this? Some .gitignore voodoo? I already use .gitignore to ignore files, but in this case its slightly different as I want to pull the file only on the first request.

I hope that makes sense.

解决方案

  • 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!

这篇关于使用Git管理框架,忽略第一次拉动后给定文件的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆