How would I go about referencing all 2D box colliders under the tag "Hole"?

I am trying to figure out how to do this so that I can easily make push block puzzles have multiple holes blocking the exit but allow for more than one of the same solution, would I use on collision enter 2D? if so, how would I then reference the collider of that hole again to reset the puzzle if the player messes up and lets the block that activates the switch at the end fall into a hole? as of right now I have the code set up for only 1 hole, here is that code.

using UnityEngine;

public class PushCrate : MonoBehaviour
{
    Rigidbody2D m_Rigidbody;
    public Transform hole;
    public BoxCollider2D hbc;
    public BoxCollider2D cbc;
    public Transform pcs;
    public Transform pb;
    public Transform bs;
    bool inHole = false;
    public Vector3 offset;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        m_Rigidbody = GetComponent<Rigidbody2D>();
    }
    void Update()
  {
    if (pb.position != bs.position)
    {
      if (Input.GetKeyDown(KeyCode.R) == true)
      {
        transform.position = pcs.position;
        if (inHole == true)
        {
            m_Rigidbody.constraints = RigidbodyConstraints2D.FreezeRotation;
            hbc.GetComponent<Collider2D>().enabled = true;
            cbc.GetComponent<Collider2D>().enabled = true;
        }
      }
    }
  }
    void OnCollisionEnter2D(Collision2D collisionInfo)
   {
    if (collisionInfo.collider.tag == "Hole")
    {
        transform.position = hole.position + offset;
        m_Rigidbody.constraints = RigidbodyConstraints2D.FreezeAll;
        hbc.GetComponent<Collider2D>().enabled = false;
        cbc.GetComponent<Collider2D>().enabled = false;
        inHole = true;
    }
   }
}

You are very nearly there. Instead of creating a reference to a single hole that you link in your script, you can query the gameobject that you collided with in the Collision2D that is passed to your OnCollisionEnter2D function. That gameobject is a reference to the object that was collided with.

I understand what your saying, but I don’t understand exactly how to reference the game object, can you give me an example of how I would do that? thanks!

The Collider2D has the reference. Simply refer to collisionInfo.gameObject to use it. You can then access it’s transform, as well as use GetComponent to access any components you need such as the Rigidbody2D and Collider2D.

EDIT: In fact, now that I look at the link I posted myself, I see that Collision2D has a reference to all of that information embedded directly in in so you wouldn’t even have to use GetComponent or the gameObject.transform property. You can get it all directly from collisionInfo.

You can read more details about what is contained in Collision2D here.
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Collision2D.html