Github, based in San Francisco, is an online platform that allows coders to collaborate with each other on their work.
It is used by employees at many big companies, including Microsoft.
Microsoft said it was paying $7.5bn (£5.6bn) in stock to achieve the deal, which is due to be completed before the end of the year. It said Github would continue to operate independently.
“We recognise the community responsibility we take on with this agreement and will do our best work to empower every developer to build, innovate and solve the world’s most pressing challenge,” said Microsoft’s chief executive Satya Nadella in a statement.
It added that Github is currently used by more than 28 million developers, who in turn represent more than 1.5 million organisations across a range of industries.
The business will be led by Nat Friedman, the founder of Xamarin – a mobile software development service acquired by Microsoft in 2016.
Microsoft described Mr Friedman as being an “open source” veteran.
The term refers to the principle that code is made publicly accessible so that others can inspect, modify and share it.
Microsoft added that Github’s current chief executive, Chris Wanstrath, will move elsewhere in its corporation to work on strategic software initiatives.
Github’s basic service is free, but it charges a monthly fee of up to $21 per user for extra services including round-the-clock support and the ability to give team members different levels of access.
Takeover worries
“Github offers transparency – it’s a very effective, no-fuss tool to run projects globally while allowing many developers to contribute,” commented Malcolm Barclay, a UK-based app developer.
“Some are nervous because of what Microsoft has done with past purchases – Skype for example – and the worry is that Github could be destroyed.
“Many of Microsoft’s takeovers are driven by user numbers, and Github has a lot of users.
“Presumably it wants something from them, but we don’t know what that is.”
The BBC is among those to use Github to share some of its open source code.
Microsoft used to run a rival service called Codeplex, but shut it down last year saying that Github had become the “de facto place for open source sharing”.
Bloomberg, which had earlier reported a deal would be announced, had noted that Github was last valued in 2015 at $2bn.
BBC