The easiest way is obviously as described in the MSDN article Share your code with Visual Studio 2017 and VSTS Git.
Create a new local Git repository for your project by selecting Add to Source Control in the status bar in the lower right hand corner of Visual Studio. This will create a new repository in the folder the solution is in and commit your code into that repository.
In the Push view in Team Explorer, select the Publish Git Repository button under Push to Visual Studio Team Services.
Connect Remote Source Control and enter your repository name and select Publish Repository.