1
0
mirror of synced 2025-12-20 18:36:31 -05:00

Hello git history spelunker!

Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
This commit is contained in:
Vanessa Yuen
2020-09-27 14:10:11 +02:00
parent fa8bb2322f
commit 3df90fc9b8
28386 changed files with 1723440 additions and 3 deletions

View File

@@ -0,0 +1,37 @@
---
title: Dealing with non-fast-forward errors
intro: 'Sometimes, Git can''t make your change to a remote repository without losing commits. When this happens, your push is refused.'
redirect_from:
- /articles/dealing-with-non-fast-forward-errors
versions:
free-pro-team: '*'
enterprise-server: '*'
---
If another person has pushed to the same branch as you, Git won't be able to push your changes:
```shell
$ git push origin master
> To https://{{ site.data.variables.command_line.codeblock }}/<em>USERNAME</em>/<em>REPOSITORY</em>.git
> ! [rejected] master -> master (non-fast-forward)
> error: failed to push some refs to 'https://{{ site.data.variables.command_line.codeblock }}/<em>USERNAME</em>/<em>REPOSITORY</em>.git'
> To prevent you from losing history, non-fast-forward updates were rejected
> Merge the remote changes (e.g. 'git pull') before pushing again. See the
> 'Note about fast-forwards' section of 'git push --help' for details.
```
You can fix this by [fetching and merging](/articles/getting-changes-from-a-remote-repository) the changes made on the remote branch with the changes that you have made locally:
```shell
$ git fetch origin
# Fetches updates made to an online repository
$ git merge origin <em>YOUR_BRANCH_NAME</em>
# Merges updates made online with your local work
```
Or, you can simply use `git pull` to perform both commands at once:
```shell
$ git pull origin <em>YOUR_BRANCH_NAME</em>
# Grabs online updates and merges them with your local work
```