Microsoft Corp. said it reached an agreement to buy GitHub Inc., the code repository company popular with many software developers, for $7.5 billion in stock. The acquisition provides a way forward for San Francisco-based GitHub, which has been trying for nine months to find a new chief executive officer and has yet to make a profit from its popular service that allows coders to share and collaborate on their work.