0

so basically I:

  1. Made a Github repository and cloned it to my desktop
  2. Modified the README.md file from Github and forgot to pull it to my desktop
  3. Made over 10 commits from like 2 hours of code

Git won't let me push:

![rejected]
error: failed to push some refs

Git won't let me pull:

Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.

What can I do?

Posho
  • 53
  • 1
  • 6
  • 2
    I guess you modified the README.md locally? Did you try to look at your conflicts with `git diff` and try to fix them? – OznOg Sep 08 '20 at 06:50
  • you can override readme by doing the force push. Else you can go for the rebase onto. – Kunal Vohra Sep 08 '20 at 06:51
  • 1
    Fix the merge conflicts (edit the sections in the README with letters like `<<<<` or `>>>>`), stage the files, commit and push. – dan1st Sep 08 '20 at 06:58

1 Answers1

1

You should fetch the changes from the server and then merge or rebase them.

git fetch --all
git rebase origin/master
git mergetool (most likely you will have some conflicts)
git push origin master

You can solve the conflict manually or with mergetool. For manual you will change the files and run git add <file>; git rebase --continue

Or more simple solution for you can be to force push it and write readme again

git push origin master --force
martin.malek
  • 2,166
  • 2
  • 19
  • 31
  • 1
    please, do not instruct people with little confidence with git to use the `--force` option. Forcing is something an experienced user should use as little as possible. A novice user should never ever use force: this will end up opening new questions here on SO like "my history disappeared from the remote, how to fix". – Daemon Painter Sep 08 '20 at 10:36
  • git merge worked like a charm, thank you very much! – Posho Sep 08 '20 at 21:10