Такая ситуация я работаю один с iOS в Xcode (может это имеет значение)
И делаю комиты в процессе работы и вдруг вижу, что удаленная ветка отделилась почему то (наверное я что то сделал не так, но все равно странное поведение ветки при условии, что я один в этом репозитории).
Выглядит это сейчас вот так
когда пишу git push
то в output говориться, что нужно сделать git pull
сначала(как так получилось, что мне нужно делать git pull не понятно, работаю в одной ветке один...).
Ок, делаю git pull
получаю конфликт в файле Main.storyboar
, такие конфликты очень тяжело исправить(по крайней мере для меня новичка в iOS), у меня даже не получается открыть этот файл.
Выглядит вот так
Так вот теперь вопрос в том, можно как то переписать remote master
ветку?
У меня есть нормальная ветка local master
и я просто хочу залить ее в удаленный репозиторий сверху того master
который сейчас там и не делать никаких merge и pull, просто сверху ее записать как основную
Можно так?)
Вот, что получается если выполнить команду git push --force master
из ответа @KoVadim
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.
С такой командой git push --force origin master
получаю вот такой вывод
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$
правка
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")