Line
IT Knowledgebase
< All Topics
Print

How to push code from VS Code to GitHub

Step 1: Open up your VS Code editor and ensure that your project is ready to go.
For this tutorial, I am going to be using a small project that has an HTML file,
CSS file and readme file in it. This is what I want to commit to a GitHub repository.
 


Step 2: Navigate to the source control view in Visual Studio Code.
You can do this by clicking on the icon on the left-hand side or by pressing Ctrl + Shift + G. 


Step 3:
When prompted, click on the “Initialize repository” button.
This action creates a new Git repository in the current folder, allowing you to start tracking code changes.



Step 4: The source control view will now list any changes you’ve made to your project.
Select all the files you want to include in this commit and enter a descriptive commit message.
Then, hit commit to save your changes.



Step 5: Head over to GitHub.com in your browser and create a new repository.



Step 6: Follow the wizard to set up your repository.



Step 7:
Once created, copy the repository’s URL from the quick setup section.



Step 8: Switch back to your VS Code editor. Click on the ellipsis () in the source control view,
select Pull/Push from the drop-down menu, and choose Push to…



Step 9: You will be prompted that the repository has no remotes to push to, click on the “Add Remote” button.



Step 10: Paste the URL you copied from GitHub and give it a name.



Step 11: VS Code will now display a button allowing you to push your code into GitHub.
Click on the “Publish Branch” button to complete the process.



Step 12: Your code is now pushed to GitHub! You can head over to your GitHub repository in the browser
and refresh the page to see your code there.

Congratulations! You’ve successfully pushed your Visual Studio Code project to GitHub.
From here, you can continue making changes to your code, committing them, and syncing them to GitHub.
Remember, mastering this process is essential for collaborating with others and managing your code effectively.



Credit : https://www.techielass.com/how-to-push-code-from-vs-code-to-github/  

Messenger