Getting Started with Git: Clone Repositories, Manage Branches, and Push Changes

Git is a distributed version control system that enables developers to track file changes and collaborate on projects efficiently.

Before proceeding, verify that Git is installed on your system by running git --version in your terminal. On Windows, you can access Git through several applications available after installation.

Git Bash provides a Unix-like bash environment for running Git commands directly. Git GUI offers a graphical interface for those preferring visual tools over command-line operaitons. Git CMD allows execution of Git commands through the Windows command prompt. For beginners, Git CMD or Git Bash are recommended choices.


Cloning a Repository

To obtain a project from GitHub to your local machine, start by navigating to the target repository on GitHub. Click the "Code" button and copy the repository URL.

Open your terminal and navigate to the directory where you want the project to be stored. For example, if you want the project in a code folder on the D drive:

cd /d/code

Clone the repository using the copied URL:

git clone https://github.com/username/repository-name.git

Git creates a new folder containing all project files. Navigate into it to begin working.


Creating and Publishing a New Branch

After making local moidfications to the project, you may want to create a separate branch to safely store your changes before merging them into the main codebase.

Navigate to your project directory and create a new branch with:

git checkout -b feature-x

Stage your changes:

git add .

To stage only specific files instead of all changes, replace . with the file path.

Commit your staged changes with a descriptive message:

git commit -m "Add new authentication feature"

Push the branch to the remote repository:

git push origin feature-x

On first push to a new remote, you may be prompted to authenticate with your GitHub credentials.


Switching Branches and Syncing Updates

When your branch gets merged and you need to continue development on the main codebase, switch to the primary branch and pull the latest updates.

Checkout the main branch:

git checkout main

Fetch and integrate the newest changes from the remote repository:

git pull origin main

After making your modifications to the updated code, stage the changes:

git add .

Commit with an appropriate message:

git commit -m "Fix login validation logic"

Push the updates to the remote:

git push origin main

These fundamental Git operations—cloning, branching, committing, and syncing—form the core workflow for most collaborative development scenarios.

Tags: Git Version Control GitHub Branching Beginner Guide

Posted on Thu, 24 Sep 2026 16:37:55 +0000 by Dark_AngeL