Skip to main content
March 23, 2026/2 min read

Quick Reference of Git Commands (Common Workflows)

Essential Git workflows for efficient version control

Git Command Reference Overview

This guide covers the three most common Git workflows that developers use daily. Each workflow includes the exact commands in the proper sequence.

Core Git Workflows Covered

Basic Commit and Push

The fundamental workflow for saving and uploading changes to your repository.

Branch Management

Switching between existing branches and keeping them synchronized with remote changes.

New Branch Creation

Creating new feature branches and establishing upstream tracking for first-time push.

Commit & Push

The most fundamental Git workflow combines checking your repository status, staging changes, and pushing to remote. This sequence ensures you maintain awareness of your working directory state while creating meaningful commit history:

git pull
git status
git add .
git commit -m "Message that describes what this change does"
git push

Always start with git pull to sync your local branch with remote changes, preventing merge conflicts. The git status command reveals which files have been modified, added, or deleted, giving you full visibility before staging changes.

Basic Commit and Push Workflow

1

Pull latest changes

Always start by pulling the latest changes from remote to avoid conflicts

2

Check repository status

Review which files have been modified, added, or deleted

3

Stage all changes

Add all modified files to the staging area for commit

4

Commit with message

Create a commit with a descriptive message explaining the changes

5

Push to remote

Upload your committed changes to the remote repository

Commit Message Best Practice

Write commit messages that clearly describe what the change does, not what you did. This helps team members understand the purpose of each commit.

Switch to an Existing Branch & Pull Latest Changes

When collaborating on established branches, proper synchronization prevents integration headaches and ensures you're working with the most current codebase.

NOTE: The initial git pull ensures we retrieve the complete list of branches from the remote repository, including any recently created by team members.

git pull
git status
git checkout my-branch-name
git pull
git status

This workflow is particularly critical in fast-moving development environments where multiple developers push changes throughout the day. The double-pull pattern—once on your current branch, then again after switching—guarantees you have the latest commits from both branches.

Branch Switching and Synchronization

1

Initial pull for branch list

Fetch all branches from remote to ensure you have the complete branch listing

2

Check current status

Verify the current state of your working directory before switching

3

Switch to target branch

Use checkout command to switch to your desired existing branch

4

Pull branch updates

Synchronize the branch with the latest changes from remote

5

Verify final status

Confirm you are on the correct branch with the latest updates

Why Two Git Pulls

The first git pull ensures you get a complete list of all branches from the remote repository. The second pull synchronizes your local branch with remote changes.

Create a New Branch & Push It for the First Time

Establishing a new feature branch requires careful setup to ensure proper tracking between your local and remote repositories. This workflow creates a clean foundation for new development work:

git status
git pull
git checkout -b my-branch-name
git status
git add .
git commit -m "Message that describes what this change does"
git push -u origin HEAD

The -u flag establishes upstream tracking, allowing future pushes and pulls to work seamlessly without specifying the remote branch name. Using HEAD automatically references your current branch, reducing typing and potential naming errors.

New Branch Creation Workflow

1

Check starting status

Verify your current repository state before creating a new branch

2

Pull latest changes

Ensure you have the most recent changes before branching

3

Create and switch to new branch

Use checkout -b to create a new branch and immediately switch to it

4

Verify branch creation

Check status to confirm you are on the new branch

5

Stage and commit changes

Add your changes and create the first commit on the new branch

6

Push with upstream tracking

Use push -u origin HEAD to establish upstream tracking for future pushes

Understanding Push with Upstream

The -u origin HEAD flag sets up tracking between your local branch and the remote branch, allowing you to use simple git push commands in the future.

Go Beyond Git

Mastering version control is just the beginning of your development journey. Whether you're looking to solidify your programming fundamentals or advance into specialized areas like data science and web development, structured learning accelerates your progress significantly.

We offer industry-leading coding courses and intensive bootcamps designed for working professionals and career changers. Our hands-on curriculum emphasizes practical application, with comprehensive workbooks guiding you through real-world projects that build portfolio-worthy applications. Explore our current programming offerings:

Programming Education Opportunities

Web Development Classes

Hands-on training with real-world applications and comprehensive workbooks for practical learning experience.

Python Programming Classes

Step-by-step instruction through exercises designed for students at all experience levels.

Data Science Classes

Comprehensive bootcamps combining theoretical knowledge with practical hands-on experience.

Key Takeaways

1Always start any Git workflow by pulling the latest changes to avoid merge conflicts and ensure you have current repository state
2The git status command should be used frequently to verify your current branch and understand which files have been modified
3Use descriptive commit messages that explain what the change does rather than what you did during development
4When switching to existing branches, perform an initial git pull to refresh your local branch list from the remote repository
5Creating new branches requires the -b flag with checkout, and first-time pushes need -u origin HEAD to establish upstream tracking
6The git add . command stages all modified files, but review changes with git status first to ensure you are committing intended modifications
7Proper Git workflows involve a consistent sequence of commands that should become second nature for efficient version control
8Understanding upstream tracking with push -u origin HEAD simplifies future push operations by establishing the connection between local and remote branches

RELATED ARTICLES