GitHub with VSCode Link to heading

Introduction Link to heading

I recently decided to start making a blog about my journey to “IT Knowledge”… This decision came into my mind because I s*ck in making of notes and also my English is not in the level which I would be comfort with…

My ultimate idea is to create a blog webpage with my notes and writeups powered by HUGO CMS

One of the first blogs will be how I configured my blog environment. So, we have this post about Git in VS Code

Set up Git in VS Code Link to heading

GIT Installation Link to heading

To use Git and GitHub in VS Code, first make sure you have Git installed on your computer. I installed by using Chocolatey package manager: Choco

choco install git -y

Sign into GIT in VS Code Link to heading

You can sign into VS Code with your GitHub account in the Accounts menu in the lower right of the Activity bar to enable additional features like Settings Sync, but also cloning and publishing repositories from GitHub.

sign-in

My usage of GIT Link to heading

For the moment of writing this article I am using the GIT for managing my HUGO environment and publishing static pages generated by HUGO into GitHub Pages.

Whole process is described in hugo documentation Host on GitHub Pages.

Cheatsheet Link to heading

Setup Link to heading

  • Initialize a Repository: git init
  • Clone a Repository: git clone [url]
  • Set User Information:
    • git config --global user.name "[firstname lastname]"
    • git config --global user.email "[valid-email]"

Working with Files Link to heading

  • Add Files to Stage: git add [file]
  • Unstage Files: git reset [file]
  • Commit Changes: git commit -m "[descriptive message]"
  • Show Status: git status
  • Show Changes: git diff
  • Show Staged Changes: git diff --staged

Branches and Merging Link to heading

  • List Branches: git branch
  • Create a New Branch: git branch [branch-name]
  • Switch Branches: git checkout [branch-name]
  • Merge Branches: git merge [branch]

Remote Repositories Link to heading

  • Add Remote Repository: git remote add [alias] [url]
  • Fetch Updates: git fetch [alias]
  • Pull Changes: git pull [alias] [branch]
  • Push Changes: git push [alias] [branch]

Inspect and Compare Link to heading

  • Show Commit History: git log
  • Show Commit History for a File: git log --follow [file]
  • Show Differences Between Branches: git diff branchB...branchA