Another approach is using the [full history planet](https://wiki.openstreetmap.org/wiki/Planet.osm/full) with the [Osmium Tool](https://osmcode.org/osmium-tool/) [OPL (Object Per Line) file format](https://osmcode.org/opl-file-format/) and UNIX command line tools. This is a bit more involved, but allows to retrieve the complete membership history.
Geofabrik provides [full history extracts](https://osm-internal.download.geofabrik.de/index.html) (.osh.pbf). For our example we download [oberbayern-internal.osh.pbf](https://osm-internal.download.geofabrik.de/europe/germany/bayern/oberbayern.html). On the command line we further extract a bounding box for the area of interest and output as OPL format (.opl):
osmium extract --with-history --bbox 11.751,48.0832,11.8147,48.1226 -o vaterstetten.osh.opl oberbayern-internal.osh.pbf
Then we can filter for relations with the given entity in the members list using "grep". The "sed" formats the matching lines to print relation meta data and the entity member role:
ENTITY=w228444126; grep -A1 -e "^r.* M.*$ENTITY@.*" vaterstetten.osh.opl | \
sed -e "s/^\(r.*\) i.* M.*$ENTITY@\([^,]*\).*/\1 \2/" -e "s/^\(r.*\) i.* M.*/\1 -/"
The output for [way 228444126](https://www.openstreetmap.org/way/228444126):
r2274470 v2 dV c16797536 t2013-07-02T20:43:57Z outer
r2274470 v3 dV c17398391 t2013-08-18T16:10:31Z outer
r2274470 v4 dV c64490423 t2018-11-14T16:11:18Z outer
r2274470 v5 dV c64492155 t2018-11-14T16:46:54Z -
--
r3059784 v1 dV c16797536 t2013-07-02T20:43:57Z outer
r3059784 v2 dD c64492155 t2018-11-14T16:46:54Z -
OSM files are usually ordered by type, id, version. The grep "-A1" option also prints the next line after a match or a group of consecutive matches. If that extra line is the next version of the same relation, then the entity has been removed as member, or the relation deleted ("dD"). Otherwise, if the extra line is a different relation, then the last matching version is the current and the entity still a member. The last sed expression marks those extra lines where the entity is not a member with a hyphen ("-").