VSCode Git Workflow Tutorial (Best Practice, Diagrams, Cheat Sheet)
What is git and what are some of the most common git commands?
git is a command line tool that allows you to interact with git repositories. There are a variety of commands that you can use with git, and in this article, we'll cover some of the most common ones.
git clone: This command is used to clone a git repository. This will create a local copy of the remote repository (the one that already exists on GitHub) on your machine.
git pull: This command is used to retrieve updates from a remote repository. This will fetch any new commits and merge them into your local copy of the repository.
git push: This command is used to push your local changes to a remote repository. This will send any commits that you have made locally up to the remote repository.
git commit: This command is used to create a new commit. This will take all of the changes that you have made locally and create a new commit with a message describing the changes.
git status: This command is used to check the status of your git repository. This will show you any files that have been modified or added since the last commit.
git diff: This command is used to view the differences between two versions of a file. This can be useful for seeing what has changed between commits, or for comparing your local version of a file with the version in the remote repository.
These are just some of the most common git commands, but there are many more that you can use to manage your git repositories.
Let's Learn Git In VSCode
It took me a long time to learn git on the command line. To be honest mostly it's because it's pointless to try using git without working on an actual project. And without a coding job or at least a personal project in substantial daily development, you simply won't develop the "muscle memory" for git.
But using git in terminal is such an important skill that there is simply no way around it, especially if you're looking to build a career in tech industry.
Litearlly the first thing you will be asked at your new tech job is to pull the build from the GitHub repository. And for many people it's the first time they have an opportunity to learn git.
So what are we going to learn in this vscode git tutorial (It's a YouTube video)?
This tutorial goes over the commit workflow, with push examples, resolve merge conflicts (briefly) and reset HEAD (go to the state your code was in one of the previous commits.)
Having said this I recorded this SHORT video tutorial that walks you through the process in Visual Studio Code.
If you still don't know Git it's really worth going through this video to avoid any regrets later, especially after you're hired at your first job 🙂
Chapters In This Video
- 00:00 How to use Git in VSCode (command line and UI)
- 00:10 You don’t need Git Extensions just use built-in Source Control button
- 00:21 Download Git for Windows 7 10 11 32 bit or 64 bit
- 00:37 Install Git on Windows 7 10 11 32 64 bit
- 00:55 Make sure Git is installed by checking version on command line
- 01:08 Open GitHub and VSCode (Visual Studio Code) side by side
- 01:21 VSCode Git Create New Remote Repository
- 01:38 Git Init Instructions: Create a new repsository in terminal
- 01:44 Start New Git Project (Create New Folder)
- 02:04 Select Project Folder
- 02:24 Open New VSCode Terminal
- 02:35 run git init to initialize new git project on command line (bash, terminal)
- 03:37 stage commit push workflow
- 04:15 git add file
- 04:33 git commit -m “commit message”
- 05:03 git branch -M main (rename current branch)
- 05:27 git remote origin main (link local branch with remote branch)
- 05:53 git push -u origin main
- 06:35 Using vscode git UI
- 06:55 vscode git add file using the vscode UI
- 06:60 vscode git commit -m “commit message” using vscode UI (Ctrl Enter)
- 07:07 vscode git push (sync changes)
- 08:04 resolving merge conflict using vscode UI
- 08:53 git reset hard HEAD
Happy coding 🙂