Git:只推送私人配置文件来测试版本库而不是github? [英] Git: Only push private config file to test repository and not to github?
问题描述
我有一个带有 config / my_private_data.yml
文件的Rails应用程序。我想推动整个应用程序都到我的测试服务器和github。然而,当我推送到测试服务器时,我想包含私人文件。当我推送到github时,我不想包含私人文件。什么是最简单的方法呢?
您可以设置两个分支。 master
和秘密
。然后,您可以在 secret
分支中添加并提交 config / my_private_data.yml
,然后您可以将其压入主设备分支在测试服务器上。
touch config / my_private_data.yml
git checkout -b secret
git add config / my_private_data.yml
git commit -m'提交的秘密文件'
git push testserver_repo_url secret
git checkout master
git push repo_on_github master
然后执行 git checkout secret; git rebase master
如果你在master上有新的提交。
不要在 secret
上提交,如果你这样做,该提交的樱桃选择。
当然,这种方法并非全部都是好的。从我现在的想法来看,你可能无意中将秘密分支推向github。另外,如果你需要 my_private_data.yml
-file(你可以做一个 master
尽管从秘密分支签出该文件)。
I have a Rails app with a config/my_private_data.yml
file. I would like to push the entire app both to my test server and to github.
However, when I push to the test server, I want to include the private file. When I push to github, I don't want to include the private file. What is the easiest way to go about this?
You can set up two branches. master
and secret
. You can then add and commit the config/my_private_data.yml
in the secret
branch which you can then push into the master branch at the testserver.
touch config/my_private_data.yml
git checkout -b secret
git add config/my_private_data.yml
git commit -m 'Commited secret file'
git push testserver_repo_url secret
git checkout master
git push repo_on_github master
Then do a git checkout secret; git rebase master
if you have new commits on master.
Don't commit on secret
and if you do, do a cherry pick of that commit.
Certainly, not all is good with this approach. From what I can think now, you could inadvertently push the secret branch to github. Also, you can't really work in master
if you need the my_private_data.yml
-file (you can do a checkout of that file from the secret branch though).
这篇关于Git:只推送私人配置文件来测试版本库而不是github?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!