Restructure and move Git content (#18336)
* Rename map topic * Delete map topic * Rename map topic * Add redirect * Remove last two map topics * Move article on adding a remote into a long-form guide * Move article on changing a remote's URL * Move articles on renaming and removing remotes * Move remote URL article * Fix typo * Remove category index file * Move a few articles to the new category * Move a few more files * Move managing remote repos article * Move the rest of the getting started with git map topic * Move the first half of the using git map topic * Move the rest of the articles and 🔥 the directory * Fix failing test * Remove Using Git from product index * Apply suggestions from code review Co-authored-by: Laura Coursen <lecoursen@github.com> * Apply suggestions from code review Co-authored-by: Laura Coursen <lecoursen@github.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
---
|
||||
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
|
||||
- /github/using-git/dealing-with-non-fast-forward-errors
|
||||
versions:
|
||||
free-pro-team: '*'
|
||||
enterprise-server: '*'
|
||||
github-ae: '*'
|
||||
---
|
||||
|
||||
If another person has pushed to the same branch as you, Git won't be able to push your changes:
|
||||
|
||||
```shell
|
||||
$ git push origin main
|
||||
> To https://{% data variables.command_line.codeblock %}/<em>USERNAME</em>/<em>REPOSITORY</em>.git
|
||||
> ! [rejected] main -> main (non-fast-forward)
|
||||
> error: failed to push some refs to 'https://{% 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](/github/getting-started-with-github/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
|
||||
```
|
||||
Reference in New Issue
Block a user