-1

I can't push my files to Github. Error:

Pushing to https://github.com/Brogolem35/project.git
To https://github.com/Brogolem35/project.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/Brogolem35/project.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I don't know how to fix it. I tried Git Bash too. It gives me the same problem.

Brogolem35
  • 101
  • 12
  • Possible duplicate of [What does "Git push non-fast-forward updates were rejected" mean?](https://stackoverflow.com/questions/4684352/what-does-git-push-non-fast-forward-updates-were-rejected-mean) – phd Jul 24 '17 at 14:51

4 Answers4

1

You either:

  1. Do git pull ..., try to merge and solve the conflicts if any, then you will be able to git push OR
  2. Do git push -f .... But be careful about this one, you should use this only if you rebased your local repository and wants to push to a non-public branch.

The first one is the safest option if you are not sure what to do.

Alberto Trindade Tavares
  • 10,056
  • 5
  • 38
  • 46
1

Please read the message:

error: failed to push some refs to 'https://github.com/Brogolem35/project.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Before you can push your changes you have to pull the remote changes.

0

The original poster asked about doing it in Git GUI. I had the same problem and resolved it by using Merge menu option enter image description here

Yar
  • 4,543
  • 2
  • 35
  • 42
-1

i had the same problem .

i used

    git push origin master --force

it worked perfect.

Aj511
  • 1
  • 1
  • 2
  • This is incredibly bad advice without explaining what the `--force` flag does. `--force` will **forcefully** overwrite the history on the remote and is of course super destructive. Use with caution. – Phillip May 23 '22 at 14:29