Using Git & GitHub In Visual Code Studio

Using Git & GitHub In Visual Code Studio

Learning Git inside of visual code studio makes the clunkiness of using a command line Git Bash a thing of the past, I love that visual code studio has a terminal built in. Couple it with a couple sweet extensions, and you’ve got it MADE!

Extensions You Need

The 1st one I recommend you download is GitLens

This extension is amazing because not only does it visually keep track of the branch you are in and the commits you’ve entered, but it also has a blame line feature you can see in the image below.

It tells you who committed the change, and when. Wondering what branch you are in? Or if you remembered to commit and push your changes to GitHub? There’s a side panel view for that!

There is ALSO a Github Extension that allows you to see if you have any pull request branches, anything waiting for your review, or perhaps a team member assigned some stuff to you on the remote server and you need to get it done but your deep in code thought, well now you’ve got a visual notification right there for you to see and prioritize. Pretty much removes the need to git log and git branch.

Here are some useful commands you are going to need in Git

cd (folder name) // Allows You To Move Up Into The Next Specific Folder In The Directory

cd - // Navigate To Previous Directory

cd / // Navigate to Root Directory

ls // Check Content In Current Local Folder

mkdir // Create Local Directory

$ git config --global user.name “YOUR NAME”// Sets Name You Want Attached To Your Work

$git config --global user.email”// Sets Email Attached To Your Commits

$ git init // Initializes A Local Folder As A Git Repository

$ git add // Add File(s) To Index AKA Staging

$ git status // Check Status Of Working Tree — Will Tell You What Documents Have Changes

$ git commit -m “your message here”// Commit The Changes In Index.

$git commit // Opens a VIM in Visual Code Studio for you to type a subject and body message. To exit VIM press ESC+Shift+ ; +w+q

$ git log // Shows Most Recent Commits. Press ‘q’ to exit log

$ git push // Push To Remote Repository Such as GitHub

$ git pull // Pull Latest From Remote Repository

$ git clone // Clone Remote Repository Into A New Directory On Your Local Machine

$ git branch // Let You Know If You Are On Main Or Branch

$ git checkout -b (branch name)// Creates A New Branch

$ git checkout (branch name)// You Will Switch To That Specified Branch. BE SURE TO COMMIT INTENDED CHANGES BEFORE SWITCHING BRANCHES

$ git branch -D (branch name) // Deletes The Entire Branch

$ git merge // Combines Remote Tracking Branch To Local Branch

$ git merge (branch name)// Combines Specific Branch’s History To Current Branch (Done In Pull Requests)

What If You Need To Pull Code From Github? How Does That Work?

If you need to pull code from a remote repository, you simply go to the source page, and you find this little copy html button.

You get that and you just type in git clone (paste URL). Once you do that, all the files in that git repository are copied to your local drive!

Git is pretty amazing. Its something I never thought I needed. I used to think it was just some website for geeks, but now that I’m using it, its pretty clear that it is FOR SURE made for geeks!

World Famous Coding Dad Joke #57:

Question: Why Did The Programmer Quit His Day Job?

Answer: Because he didn’t get Arrays