Ветви Gitlab «разошлись» после объединения двух веток - PullRequest
0 голосов
/ 03 сентября 2018

У меня была ветка с именем refactor, которую я слил в master, используя веб-интерфейс Gitlab. Это также удалило ветку с исходным кодом.

Вернувшись в оболочку, я заметил, что git все еще думал, что это ветка refactor (которой больше не существует). Я попытался переключить ветки обратно на master, но я проделал некоторую дальнейшую работу локально, что привело к несохраненным изменениям. Я нашел новую (для меня) команду с именем stash, поэтому попытался:

$ git stash
warning: LF will be replaced by CRLF in Prec/EnquiryForms/wizard/manifest.xml
The file will have its original line endings in your working directory.
Saved working directory and index state WIP on refactor: 3b174f5 Updated package

Тогда я мог бы переключиться на master

$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

Я пытался применить тайник, но возникли конфликты

$ git stash apply
Auto-merging Prec/Scripts/_wizard/manifest.xml
CONFLICT (content): Merge conflict in Prec/Scripts/_wizard/manifest.xml
Auto-merging Prec/EnquiryForms/wizard/manifest.xml
CONFLICT (content): Merge conflict in Prec/EnquiryForms/wizard/manifest.xml
Auto-merging Prec/Prec.Manifest.xml
CONFLICT (content): Merge conflict in Prec/Prec.Manifest.xml

Так что я все равно попытался совершить коммит и теперь застрял.

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        both modified:   Prec/Prec.Manifest.xml
        both modified:   Prec/EnquiryForms/wizard/manifest.xml
        both modified:   Prec/Scripts/_wizard/manifest.xml

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        Prec/Lookups/CLTYPES/

no changes added to commit (use "git add" and/or "git commit -a")


$ git stash list
stash@{0}: WIP on refactor: 3b174f5 Updated package


$ git add .


$ git commit -m "some changes"
[master d5892a6] some changes
 4 files changed, 112 insertions(+)
 create mode 100644 Prec/Lookups/CLTYPES/manifest.xml


$ git push origin master
To gitlab.example.com:repo/new.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@gitlab.example.com:repo/new.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.

На данный момент я сделал git pull

$ git pull
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 1 (delta 0)
Unpacking objects: 100% (1/1), done.
From gitlab.example.com:repo/new-coi
   c521196..bce53c1  master     -> origin/master
Auto-merging Prec/Scripts/_wizard/manifest.xml
CONFLICT (content): Merge conflict in Prec/Scripts/_wizard/manifest.xml
Auto-merging Prec/EnquiryForms/wizard/manifest.xml
CONFLICT (content): Merge conflict in Prec/EnquiryForms/wizard/manifest.xml
Auto-merging Prec/Prec.Manifest.xml
CONFLICT (content): Merge conflict in Prec/Prec.Manifest.xml
Automatic merge failed; fix conflicts and then commit the result.

Сейчас я нахожусь в следующем состоянии

$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 5 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

Я не очень понимаю, что здесь произошло или как это исправить. Я хочу, чтобы те изменения, которые я сделал после слияния ветвей, были зафиксированы в главной ветке. Git должен быть таким же современным, как мой локальный каталог.

1 Ответ

0 голосов
/ 04 сентября 2018

После того, как вы извлекли из мастера, ваши изменения вступают в конфликт с некоторыми изменениями, переданными в мастер (пока вы работали над своими изменениями). Git не может объединить изменения самостоятельно, хочет, чтобы вы разрешили конфликт, а затем снова нажали.

Ниже приведены шаги по разрешению конфликтов и повторной отправке в удаленное хранилище: Разрешение конфликтов слияния с помощью командной строки

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...