简体   繁体   中英

git-ignoring files based on remote?

Is it possible to ignore specific files in git only for certain remotes? eg, I'm storing AWS S3 credentials ( s3.yml ) in a file for an app hosted on Heroku, thus I need to check s3.yml into my repo for the deploy to work. However, I'd like to publish the source to GitHub as well, so I would be wise to keep s3.yml out of the repo. I would imagine it working something like

#.gitignore
github:config/s3.yml

but haven't been able to find anything in the git docs. Is this possible? Or do I need to maintain two separate repos?

Thanks!

That file is always going to live in the repo if you publish it as is. Even if you created a branch and git-rm'd the file, people would always be able to check out the version that still had the file. I don't see any way of using a single repository while keeping a single file inaccessible on a remote.

The core problem is that, as a distributed SCM, each repository has a full revision history. Since the changelists are cryptographically signed based on their content, it's not possible to erase a file without changing the hash of each changelist all the way back to when the file was added. This is something git can do, but at that point you have two separate repositories that won't be able to directly/easily push/pull.

Heroku has config-vars for this sort of thing. Their opinion seems to be that the s3 information shouldn't be checking into Git. Check out this link for more information about how they're expecting this sort of thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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