This situation I work alone with iOS in Xcode (maybe it matters)
And I do commits in the process of work and suddenly I see that the remote branch was separated for some reason (probably I did something wrong, but still the strange behavior of the branch, provided that I am alone in this repository).
It looks like this now.
when I write git push then in output it says that you need to do git pull first (as it happened, what I need to do is not clear git pull, I work in one branch ...).
Ok, I do git pull I get a conflict in the Main.storyboar file, such conflicts are very hard to fix (at least for me a newbie in iOS), I can't even open this file.
It looks like this
So now the question is, can I somehow rewrite the remote master branch?
I have a normal local master branch and I just want to upload it to the remote repository on top of the master that’s there now and don’t do any merge and pull, just write it on top as the main one
Can this be so?)
This is what happens if you run the git push --force master from the @KoVadim response
Admins-MacBook-Pro:Fitzz admin$ git push --force 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. With such a command git push --force origin master I get this output
Admins-MacBook-Pro:Fitzz admin$ git push --force origin master Counting objects: 39, done. Delta compression using up to 8 threads. Compressing objects: 100% (39/39), done. Writing objects: 100% (39/39), 11.10 KiB | 0 bytes/s, done. Total 39 (delta 23), reused 0 (delta 0) remote: GitLab: You are not allowed to force push code to a protected branch on this project. To https://gitlab.com/alekseytimoshchenko/FitzzIOS.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://gitlab.com/alekseytimoshchenko/FitzzIOS.git' Admins-MacBook-Pro:Fitzz admin$ edit
Admins-MacBook-Pro:Fitzz admin$ git fetch Admins-MacBook-Pro:Fitzz admin$ git checkout master Already on 'master' Your branch and 'origin/master' have diverged, and have 7 and 1 different commits each, respectively. (use "git pull" to merge the remote branch into yours) Admins-MacBook-Pro:Fitzz admin$ git merge Auto-merging Fitzz/Main.storyboard CONFLICT (content): Merge conflict in Fitzz/Main.storyboard Auto-merging Fitzz/Info.plist CONFLICT (content): Merge conflict in Fitzz/Info.plist Auto-merging Fitzz/CameraViewController.swift CONFLICT (add/add): Merge conflict in Fitzz/CameraViewController.swift Auto-merging Fitzz.xcodeproj/project.pbxproj CONFLICT (content): Merge conflict in Fitzz.xcodeproj/project.pbxproj Automatic merge failed; fix conflicts and then commit the result. Admins-MacBook-Pro:Fitzz admin$ git checkout --ours -- Fitzz.xcodeproj/project.pbxproj Admins-MacBook-Pro:Fitzz admin$ git checkout --ours -- Fitzz/CameraViewController.swift Admins-MacBook-Pro:Fitzz admin$ git checkout --ours -- Fitzz/Info.plist Admins-MacBook-Pro:Fitzz admin$ git checkout --ours -- Fitzz/Main.storyboard Admins-MacBook-Pro:Fitzz admin$ git status On branch master Your branch and 'origin/master' have diverged, and have 7 and 1 different commits each, respectively. (use "git pull" to merge the remote branch into yours) You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge) Unmerged paths: (use "git add <file>..." to mark resolution) both modified: Fitzz.xcodeproj/project.pbxproj both added: Fitzz/CameraViewController.swift both modified: Fitzz/Info.plist both modified: Fitzz/Main.storyboard no changes added to commit (use "git add" and/or "git commit -a") 
