Skip to main content
In this guide, you’ll master the core Git workflows for local development: initializing repositories, configuring identity, staging and committing changes, branching and merging, and cloning from remote hosts like GitHub and Azure Repos. We’ll also explore graphical tools in Visual Studio Code, Visual Studio, and GitHub Desktop.

1. Configure Your Identity

Before you make any commits, set up your name and email. These values appear in each commit’s metadata.
Use --global to apply settings across all repositories on your machine. To override identity per-repo, omit --global and run the commands inside the repository directory.

2. Initialize a Git Repository

  1. Create and enter a new project folder:
  2. Initialize Git:
    Output:
  3. Create a file and check status:
    You should see hello.txt listed as an untracked file.
  4. Stage and commit:
  5. Review your commit history:
    Example output:

Common Git Commands


3. Branching and Feature Workflows

  1. Create and switch to a new branch:
    Output:
  2. Update hello.txt to:
  3. Stage and commit your change:
The image shows a Visual Studio Code interface with a file named "hello.txt" open, containing the text "Hello".
  1. Visualize the branch history:
    Output:

4. Merging Changes Back into Master

Switch to master and merge:
You’ll typically see a fast-forward merge:
Verify the merged content:

5. Cloning a Remote Repository

5.1 From GitHub

  1. On GitHub New Repository, create my-cool-project (private), initialize with a README.
The image shows a GitHub interface for creating a new repository, with options to set the repository name, description, visibility, and initialization settings.
  1. Clone via HTTPS:
  2. Add, commit, and push a file:
    You’ll now see hello.txt in your GitHub repo.

5.2 Using Visual Studio Code

Open the cloned folder in VS Code. The Source Control view shows your changes:
The image shows a text editor with a file named "hello.txt" containing the text "Hello world!" and "I have added some stuff today!" It also displays a Git changes panel indicating the file has been modified.

5.3 Inside Visual Studio

In Visual Studio, use the Git Changes window to stage, commit, and push:
The image shows a Visual Studio interface with a Git Changes panel open, displaying a commit with the message "Added stuff" and a list of changed files.

5.4 Cloning from Azure Repos


6. GUI Client: GitHub Desktop

GitHub Desktop provides an intuitive interface for cloning, committing, and pushing. After installing and signing in, configure your identity:
The image shows a Git configuration screen where a user can choose to use their GitHub account name and email or configure them manually. It includes fields for name and email, with a space-themed illustration on the right.
Clone your repo and open it in VS Code. When prompted:
The image shows a Visual Studio Code window with a prompt asking if the user trusts the authors of the files in a specific folder. The background also displays a GitHub authorization page in a browser.
Only trust workspaces you recognize. Untrusted code can run arbitrary scripts on your machine.

Summary

You now know how to:
  • Configure Git identity
  • Initialize, stage, and commit a repository
  • Create, switch, and merge branches
  • Clone and contribute to remote repositories
  • Use GUI tools like VS Code, Visual Studio, and GitHub Desktop
With these skills, you’re ready to collaborate efficiently across any Git-based project.

References

Watch Video