0

I started work before cloning or pulling and this is the result

The problem is I have two branches with the same name "master" one of them on the local side and one on the git remote.

enter image description here

How can I solve this?

Holger Just
  • 52,918
  • 14
  • 115
  • 123
  • 2
    Possible duplicate of [How do you merge two Git repositories?](https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories) – Josh Lee Aug 21 '18 at 12:20
  • @JoshLee completely i can't because i can not merge master to master which they are the same brunch –  Aug 21 '18 at 12:52
  • I think [Git refusing to merge unrelated histories on rebase](https://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories-on-rebase) might be helpful, specifically the `--allow-unrelated-histories` option (It can be used with `git pull` in addition to `merge` and `rebase`) – bto Aug 21 '18 at 19:29

1 Answers1

0

If you don't have anything important on the remote repository you could force push your local history git push --force origin master. Note that other people should then clone again the repository to avoid history conflicts.

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52
Miguel Berrío
  • 311
  • 1
  • 7
  • $ git push --force master origin/master fatal: 'master' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. –  Aug 21 '18 at 12:32
  • Oh, I had it the other way arround. It should be `git push -f `. For your case it should be `git push -f origin/master master`. Hope it works! – Miguel Berrío Aug 21 '18 at 12:50
  • 1
    Then you can use `git pull origin master --allow-unrelated-histories`. This will create a merge commit of both branches, but you'll have the hole history there. – Miguel Berrío Aug 21 '18 at 13:17
  • I don't have tow branches I have just one. So I can't merge –  Aug 21 '18 at 13:20
  • But you do have two brances, master and origin/master. In git they are two branches of two repositories (remote and local). – Miguel Berrío Aug 21 '18 at 13:24