Hi William Thompson,
Thank you for reaching out to Microsoft Q & A forum.
To connect an existing Visual Studio 2022 project to a GitHub repository, follow these steps:
1.Ensure Git is Installed in Visual Studio 2022
Visual Studio includes Git by default. If it's not already configured, navigate to Tools > Options > Source Control > Plug-in Selection and choose Git from the available options.
2.Open Your Project in Visual Studio
Launch Visual Studio 2022 and open the project you want to connect to GitHub.
3.Sign In to Your GitHub Account
Go to View > GitHub (or Team Explorer, depending on your setup).
In the Team Explorer window, select Connect and sign in to your GitHub account if you haven't already.
4.Configure the Remote URL for Your GitHub Repository
Open Team Explorer by selecting View > Team Explorer.
In the Branches section, right-click your main branch (usually main or master) and select Manage Branches.
In the Git Changes window, click the Settings icon.
In Repository Settings, under the Remotes section, click Add.
Enter the remote name (commonly origin for the primary remote) and paste your GitHub repository’s URL, which you can find by clicking the Code button in GitHub and copying the HTTPS URL.
5.Push Your Project to GitHub
After setting the remote URL, navigate to View > Git Changes. You should now see that your project is linked to your GitHub repository.
Commit any changes by clicking Commit All, add a commit message, and then press Push to upload your local changes to GitHub.
6.Confirm Your Project on GitHub
Visit your GitHub repository in a browser to confirm the project files have been successfully uploaded. You should also see your commit history reflected.
For more detailed guidance, refer to the official Visual Studio documentation.Please feel free to contact us if you have any additional questions. If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.
Thank you.
git - How to add a new project to Github using VS Code - Stack Overflow
How do I connect my existing Visual Studio 2022 project to an existing github repository? - Stack Overflow
Git issues with visual studio 2022
Using github and VS Code?
Here are the detailed steps needed to achieve this.
The existing commands can be simply run via the CLI terminal of VS-CODE. It is understood that Git is installed in the system, configured with desired username and email Id.
Navigate to the local project directory and create a local git repository:
git initOnce that is successful, click on the 'Source Control' icon on the left navbar in VS-Code.One should be able to see files ready to be commit-ed. Press on 'Commit' button, provide comments, stage the changes and commit the files. Alternatively you can run from CLI
git commit -am "Your comment"Now you need to visit your GitHub account and create a new Repository. Exclude creating 'README.md', '.gitIgnore' files. Also do not add any License to the repo. Sometimes these settings cause issue while pushing in.
Copy the link to this newly created GitHub Repository.
Come back to the terminal in VS-CODE and type these commands in succession:
git remote add origin <Link to GitHub Repo>//maps the remote repo link to local git repogit remote -v//this is to verify the link to the remote repogit push -u origin master// pushes the commit-ed changes into the remote repo
Note: If it is the first time the local git account is trying to connect to GitHub, you may be required to enter credentials to GitHub in a separate window.
- You can see the success message in the Terminal. You can also verify by refreshing the GitHub repo online.
This feature was added in 1.45, demoed here.
Launch the command palette Ctrl+Shift+P, run Publish to Github, and follow the prompt. You will be given the choice between a private and public repository, so be careful that you choose the right one.

It may ask you to login to github. It will then prompt for the repo name (defaults to the name of the folder), and for creating a .gitignore file (defaults to empty .gitignore). Just hit enter if you are fine with the defaults. When you are done it should give you a popup notification in the bottom right with a link to the repo https://github.com/<username>/<reponame>
Minor warning: if your project already has a .gitignore file in it this process will overwrite it
im trying to commit/push my current cpp code to a remote/online github repository but when i tty to do that, visual studio just pushes to a local repository. how do i fix this? fyi im pretty new to git/github and visual studio