Premium lesson

Pushing & Pulling Commits in Git

Git·4 min read·Jan 1, 2025

In Git, pushing, pulling, and fetching refer to three correlated operations used to keep local and remote repositories in sync, where:

  • Pushing means uploading the changes made in a local repository to a remote repository, making them available to other developers.

  • Pulling means downloading and integrating the changes made by you or other developers to a remote repository into a local repository.

  • Fetching means downloading the changes made to a remote repository without integrating them.

Local vs remote branches

A local branch is a branch that only exists on your local copy of the Git repository, and that only you can view, create, modify, and delete.

A remote branch, on the other hand, is a branch that exists on the remote repository, whose commits can be downloaded (i.e. pulled) and updated (i.e. pushed) by you and other developers, and that serves as a reference point for local branches.

In practice, local branches are usually connected to remote branches, then called upstream branches, which allow developers to push and pull commits to and from the remote repository, ensuring that everyone's work is synchronized.

Checking if a branch is "ahead" or "behind"

When working with remote repositories, it is very common for local branches to get out of sync with their corresponding upstream branches.

When the commits of a local branch have not yet been pushed to the remote repository, the local branch is then considered ahead of the remote branch, as it has more commits.

icon light bulb key

Unlock the Build CLI Apps in JavaScript & Node.js module

Learn how to build, integrate, and safeguard scalable CLI tools, scripts, and apps with JavaScript, Node.js, npm, and Git.

You get immediate access to:

  • 45 focused lessons across JavaScript, Node.js, npm, and Git
  • 17 real-world projects with commented solutions
  • Ongoing updates to this bundle
  • Lifetime access to this bundle
Unlock this module