Skip to content

Commit

Permalink
Tipify reset-master
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalarangelo committed Apr 1, 2024
1 parent cff4277 commit 19c84bb
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions content/snippets/git/s/reset-master.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
---
title: Reset master to match remote
type: snippet
title: Reset your local master branch to match remote
shortTitle: Reset master to match remote
type: tip
language: git
tags: [repository,branch]
cover: old-consoles
dateModified: 2021-04-13
excerpt: Learn how to quickly and easily reset your local `master` branch to match the one on the remote.
dateModified: 2024-03-31
---

Resets the local `master` branch to match the one on the remote.
If you've ever worked with Git, chances are you've encountered a situation where your local `master` branch is **out of sync with the remote**. This can happen if you've made some local changes to the `master` branch and want to reset it to match the one on the remote.

- Use `git fetch origin` to retrieve the latest updates from the remote.
- Use `git checkout master` to switch to the `master` branch.
- Use `git reset --hard origin/master` to reset the local `master` branch to match the one on the remote.
The first step to fix this is to make sure you have the **latest updates** from the remote. You can do this by using `git fetch origin`. After that, you can **switch** to the `master` branch using `git checkout master` and **reset** it to match the one on the remote using `git reset --hard origin/master`.

```shell
git fetch origin
git checkout master
git reset --hard origin/master
# Syntax
# git fetch origin
# git checkout master
# git reset --hard origin/master

# Examples
git fetch origin
git checkout master
git reset --hard origin/master
# Local `master` branch is now up to date with remote `master`
```

> [!TIP]
>
> You can follow this process for **any branch**, not just `master`. Simply replace `master` with the name of the branch you want to reset.

0 comments on commit 19c84bb

Please sign in to comment.