National Grid and union representatives reached a tentative agreement to end a bitter contract dispute that has left about 1,200 natural gas employees locked out for months in Massachusetts. The workers, including those who maintain natural gas infrastructure in National Grid's eastern Massachusetts service area, were locked out by the utility in July after a previous collective bargaining agreement expired. National Grid also serves customers in Rhode Island and New York, but workers in those states were not affected.