Skip to main content

Useful Git Commands

Review a list of useful commands to help you get started with Git on Pantheon.


This section contains useful commands to help you get started with Git on Pantheon.

Work with Remote Changes

Fetch

The fetch command retrieves changes from your remote and adds them to your local. Replace $branch-name with the name of your branch in the example below.

Pull

The pull command retrieves changes from your remote and adds them to a local branch that contains changes that have not been committed to the remote yet. Replace $branch-name with the name of your branch in the example below.

Common Commands

Set Upstream to Origin

Try setting your upstream to origin if git pull doesn't bring you origin/main the way you expect:

Push from a Local Branch to a Remote Branch with a Different Name

Replace $branch-name with the name of your branch in the example below.

Main Branch Has Diverged from Origin

The commands below will overwrite all files in the local branch with the most recent files in the main branch. Any local changes will be overwritten. This can be useful when your local files don’t match the files in the main branch.

Checkout a Specific File From Another Branch

You can check out a specific file from a local or remote branch. This is useful if you get stuck during a rebase or just want the file as it appears in another branch.

Run the command below, changing origin/$BRANCH and ``file-name.md` in the example as needed:

More Resources