[英]How to exclude a particular commit from git merge (forever)
I'm developing some web application (php, codeigniter). 我正在开发一些Web应用程序(php,codeigniter)。 Today a time to push it to github has come, but I've encountered an issue I can't manage.
今天是时候把它推向github了,但我遇到了一个我无法管理的问题。
I've got 2 branches: 我有两个分支:
By credentials I mean: database login, password, host, user; 凭证我的意思是:数据库登录,密码,主机,用户; oauth services id / secrets;
oauth服务id / secrets; encryption_key.
encryption_key。 Credentials are stored in 2 separated files within /application/config folder.
凭据存储在/ application / config文件夹中的2个单独文件中。
The idea is that I'll make all changes on dev, than merge dev into master, and pull master content to github (but master can't contain my private credentials). 我的想法是,我将在dev上进行所有更改,而不是将dev合并到master中,并将master内容拉到github(但master不能包含我的私有凭据)。
This is what I've done till now: 这就是我到目前为止所做的事情:
And it's pretty cool till now - I've got my project code on github with no credentials within. 到现在为止它非常酷 - 我的github上的项目代码没有凭据。 Next I need to make some changes in my project, so I:
接下来我需要对我的项目进行一些更改,所以我:
So now I need to make some change in dev, upload it and pull to github so I: 所以现在我需要在dev中进行一些更改,上传它并拉到github所以我:
What I expected to happen: Git will ask me which version of configs should be used in 'master' as it is different in both branches. 我期望发生的事情: Git会问我在'master'中应该使用哪个版本的配置,因为它在两个分支中都是不同的。 I will use diff to chose a 'master' verion of files (which does not contain credentials).
我将使用diff来选择文件的“主”版本(不包含凭证)。 Git will remember my choice, and in the future I will not have to chose again when I'll merge dev into master.
Git会记住我的选择,将来我不会再选择当我将dev合并到master中时。 Git works like this on one of my other projects, where dev is a master branch and instantions are it's children (In this case dev is a child and I merge child into parent).
Git在我的其他项目中就是这样的,其中dev是一个主分支,而instantions是它的子代(在这种情况下,dev是一个孩子,我将child合并为parent)。
What happened: Git just copied credentials from dev to master, did not ask me about that. 发生了什么: Git只是将凭证从dev复制到master,没有问我这个问题。 So now my master branch is 'tainted' by credentials and I can't push it to github anymore.
所以现在我的主分支被凭证“污染”,我不能再把它推到github了。
My questions are: 我的问题是:
Please let me know if anything is unclear, any help will be appreciated. 如果有任何不清楚的地方,请告诉我,任何帮助将不胜感激。
Git will only flag a conflict if files in your master branch were changed after your original branch to dev, then the same files were changed in dev. 如果主分支中的文件在原始分支后更改为dev,则Git将仅标记冲突,然后在dev中更改相同的文件。
I suggest you add a .gitignore entry for your credentials, or separate them using an ENVIRONMENT variable, in codeigniter this is very easy, all you have to do is on your apache config (vhost if your using them) is add SetEnv APPLICATION_ENV development
then you can add a folder inside application/configs
called development
, now when you are running in development environment, these configs will take precedence over the ones in the base config directory. 我建议你为你的凭证添加一个.gitignore条目,或者使用ENVIRONMENT变量将它们分开,在codeigniter中这很容易,你所要做的只是你的apache配置(vhost,如果你使用它们)是添加
SetEnv APPLICATION_ENV development
然后你可以在application/configs
添加一个名为development
的文件夹,现在当你在开发环境中运行时,这些配置将优先于基本配置目录中的配置。
This isn't so much about gitignoring files, or removing commits, but a good file structure, and environment setup to differentiate between the separate environments, you an use development
, staging
, and production
(which is the default) 这不是关于gitignoring文件,删除提交,而是良好的文件结构和环境设置,以区分不同的环境,使用
development
, staging
和production
(这是默认设置)
otherwise add a .gitignore row to tell git to ignore those certain files. 否则添加.gitignore行告诉git忽略那些特定文件。
Git ingore will help. Git ingore会有所帮助。 Read this blog post for solution.
阅读此博客文章了解解决方案。
http://blog.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/ http://blog.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/
You can include the credentials from a configuration file and add that file to .gitignore
. 您可以包含配置文件中的凭据,并将该文件添加到
.gitignore
。
The config file can consist of settings for the dev, preproduction and production environments. 配置文件可以包含开发,预生产和生产环境的设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.