How to use git add, commit and push in VS Code and Command-line
When I first learned how to use Git add, commit and push it was in the terminal.
I would see people use VS Code for Git sometimes, when I googled it, the sources were confusing and I just needed something simple. It wasn’t until I started pair-programming at work that I saw how the VS Code interface compared to using Git commands.
You can read more about Basic Git commands on Atlassian but I thought it would be helpful to show the 3 commands that I use everyday and how those translated from the Command-line/terminal to VS Code.
In your Command-line/terminal
Add a specific file like an index.html:
git add index.html
Write a commit message:
git commit -m "daily update"
Push it. (p-push it, I can’t help myself)
git push origin main
So what does this look like in VS Code?
First click on Source Control on the sidebar menu or (if you’re a hotkey junky like me, control+shift+g).
Add the file that you just made changes to by clicking the “+” . In Git this would be “git add README.md”:
In the text box write in your commit message (if you’re wanting to know how to write better commit messages I found this article helpful). Then click the check mark. In Git this is “git commit -m “Updated project links”:
Click on the More Options icon, then select “Push”.
In Git this is…. you guessed it…. “git push”:
So there you you have it!