Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Problem switching to branch stable #2746

Open
jotazzu opened this issue Jan 10, 2025 · 17 comments
Open

Q: Problem switching to branch stable #2746

jotazzu opened this issue Jan 10, 2025 · 17 comments

Comments

@jotazzu
Copy link

jotazzu commented Jan 10, 2025

After having problems updating to the new 'stable' branch from v3.8.1 I applied the command
git merge --abort

After this command the state seemed quite well but in the end I did end where I started before.
It seems to become a endless update loop.

$ git status
On branch stable
nothing to commit, working tree clean

$ git remote -v
origin https://github.com/Varying-Vagrant-Vagrants/VVV (fetch)
origin https://github.com/Varying-Vagrant-Vagrants/VVV (push)

$ git checkout stable
Already on 'stable'

$ git pull origin stable
From https://github.com/Varying-Vagrant-Vagrants/VVV

  • branch stable -> FETCH_HEAD
    Removing provision/core/nginx/apt-keys/nginx_signing.key
    Auto-merging Vagrantfile
    CONFLICT (content): Merge conflict in Vagrantfile
    Removing .github/ISSUE_TEMPLATE/monteray-virtualbox-timeouts.yml
    Automatic merge failed; fix conflicts and then commit the result.

$ git status
On branch stable
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)

Changes to be committed:
modified: .gitattributes
modified: .github/ISSUE_TEMPLATE/bug-report.yml
deleted: .github/ISSUE_TEMPLATE/monteray-virtualbox-timeouts.yml
modified: .github/workflows/vvv-provisioning.yml
modified: CHANGELOG.md
modified: README.md
modified: config/default-config.yml
modified: config/homebin/db_backup
modified: config/homebin/db_restore
modified: config/homebin/switch_php_debugmod
modified: config/homebin/vagrant_provision
modified: config/homebin/vagrant_up
modified: config/homebin/vvv_restore_php_default
modified: config/init/vvv-start.conf
modified: config/php-config/php-fpm.conf
modified: config/php-config/php-www.conf
modified: config/php-config/upstream.conf
modified: database/sql/import-sql.sh
modified: database/sql/init.sql
modified: provision/core/composer/provision.sh
modified: provision/core/deprecated.sh
modified: provision/core/env/homedir/.bash_aliases
modified: provision/core/env/homedir/.bash_profile
modified: provision/core/env/provision.sh
modified: provision/core/env/ssh/ssh_known_hosts
modified: provision/core/git/provision.sh
new file: provision/core/git/sources-ubuntu-jammy.list
modified: provision/core/mailhog/provision.sh
new file: provision/core/mariadb/config/debian.cnf
modified: provision/core/mariadb/provision.sh
new file: provision/core/mariadb/sources-ubuntu-jammy.list
modified: provision/core/memcached/config/memcached.conf
new file: provision/core/nginx/apt-keys/nginx-archive-keyring.gpg
deleted: provision/core/nginx/apt-keys/nginx_signing.key
modified: provision/core/nginx/config/nginx.conf
new file: provision/core/nginx/config/site-fallback.conf
modified: provision/core/nginx/config/sites/default.conf
new file: provision/core/nginx/default-pages/nodashboard.html
modified: provision/core/nginx/provision.sh
new file: provision/core/nginx/sources-ubuntu-jammy.list
modified: provision/core/node-nvm/provision.sh
new file: provision/core/node-ppa/sources-ubuntu-jammy.list
modified: provision/core/php/provision.sh
modified: provision/core/php/sources-ubuntu-bionic.list
modified: provision/core/php/sources-ubuntu-focal.list
new file: provision/core/php/sources-ubuntu-jammy.list
new file: provision/core/phpcs/.gitignore
modified: provision/core/phpcs/composer.json
modified: provision/core/phpcs/provision.sh
new file: provision/core/phpcs/readme.md
modified: provision/core/vvv/provision.sh
modified: provision/core/vvv/sources-ubuntu-bionic.list
modified: provision/core/vvv/sources-ubuntu-focal.list
new file: provision/core/vvv/sources-ubuntu-jammy.list
modified: provision/core/wp-cli/provision.sh
modified: provision/provision-dashboard.sh
modified: provision/provision-helpers.sh
modified: provision/provision-site.sh
modified: provision/provision.sh
modified: provision/provisioners.sh
modified: version
modified: www/default/phpinfo/index.php
modified: www/default/xdebuginfo/index.php

Unmerged paths:
(use "git add ..." to mark resolution)
both modified: Vagrantfile

$ git add Vagrantfile

This last command did not help to stop the loop. I end always with the message 'You have unmerged paths.'

@tomjn
Copy link
Member

tomjn commented Jan 10, 2025

What changes did you make to the Vagrantfile? Note that adding and committing those changes is not what you want to do, you would only do that if you wanted all VVV users to have those changes.

A git diff Vagrantfile should reveal what you changed, though since you used git add you might need to run git diff --cached

@tomjn
Copy link
Member

tomjn commented Jan 10, 2025

In the meantime abort the merge with git merge --abort, this situation happens because you made manual modifications to a VVV file then tried to pull down new changes and git doesn't know what to do

@jotazzu
Copy link
Author

jotazzu commented Jan 10, 2025

Originally I had to comment two lines in Vagrantfile related to 'vagrant-goodhosts' as it did not work properly (at least on Windows).
After the first problems when updating today I replaced the modified version of Vagrantfile with the original, but it did not help. At some point I simply deleted the local Vagrantfile. Also I've executed the Stash command at some point.

The diff 'git diff Vagrantfile' seems between the shortened version of the last master branch and a newer version. After executing 'git merge --abort' the shortened version of the master branch is reinstalled on my drive.

Executing 'git diff Vagrantfile' or 'git diff --cached Vagrantfile' now results in no output.

@tomjn
Copy link
Member

tomjn commented Jan 10, 2025

you do not want the master branch, that was deprecated a long time ago and doesn't recieve the newer versions. Move away from the master branch as soon as you can to the newer stable branch.

Otherwise your goal is to eliminate all changes so that git status says you have no untracked changes, then git pull.

A git reset --hard may help you here, as would any git GUI that lets you discard changes

@jotazzu
Copy link
Author

jotazzu commented Jan 10, 2025

Also with applying 'git reset --hard' I end in the endless update loop again:
$ git reset --hard
HEAD is now at 678f820 Merge pull request #2647 from Varying-Vagrant-Vagrants/change-from-master-to-stable-branch

$ git status
On branch stable
nothing to commit, working tree clean

$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> stable

$ git pull origin stable
From https://github.com/Varying-Vagrant-Vagrants/VVV

  • branch stable -> FETCH_HEAD
    Removing provision/core/nginx/apt-keys/nginx_signing.key
    Auto-merging Vagrantfile
    CONFLICT (content): Merge conflict in Vagrantfile
    Removing .github/ISSUE_TEMPLATE/monteray-virtualbox-timeouts.yml
    Automatic merge failed; fix conflicts and then commit the result.
GitHub
An open source Vagrant configuration for developing with WordPress - Varying-Vagrant-Vagrants/VVV

@jotazzu
Copy link
Author

jotazzu commented Jan 10, 2025

The Git editor did hide words in angle brackets. The answer at 'git pull' contained an expanded command 'git pull <remote> <branch>' where <remote> and <branch> where hidden.

@tomjn
Copy link
Member

tomjn commented Jan 10, 2025

What happens with a git fetch origin && git checkout stable?

@tomjn
Copy link
Member

tomjn commented Jan 10, 2025

Or rather this to reset to match remote branch exactly:

switch to the stable branch if you haven't already:

git checkout stable

then reset stable to what github has:

git fetch origin
git reset --hard origin/stable

@jotazzu
Copy link
Author

jotazzu commented Jan 10, 2025

$ git fetch origin && git checkout stable
error: you need to resolve your current index first
Vagrantfile: needs merge

@tomjn
Copy link
Member

tomjn commented Jan 10, 2025

Originally I had to comment two lines in Vagrantfile related to 'vagrant-goodhosts' as it did not work properly (at least on Windows).

In future if you make any changes to a VVV file they need to be undone before you try to pull down any changes and restored afterwards

@tomjn
Copy link
Member

tomjn commented Jan 10, 2025

$ git fetch origin && git checkout stable
error: you need to resolve your current index first
Vagrantfile: needs merge

Yeah you need to abort any merges etc and get back to the git status normal state, git merge --abort should help here but git status will list the abort command.

Whatever you do, do not add or try to commit the vagrantfile changes or try to resolve merge conflicts, it will make things more complicated as you'll then need to undo that

@tomjn
Copy link
Member

tomjn commented Jan 10, 2025

If you have something like VSCode or a Git GUI it will show all the staged/unstaged changes as well as options to discard/unstage them

@jotazzu
Copy link
Author

jotazzu commented Jan 10, 2025

Now the stable branch seems to be installed although I always got the merge conflict messages. Git GUI does not display any staged/unstaged changes any more. Also the file 'version' contains the proper version number 3.13.2 of the last stable.

May be I've made a mistake when I created a local 'stable' branch and did pull into it ('git pull origin stable'). In one of my last tries I executed 'git pull origin master' where origin is related to the stable branch of the Github repository and master is the local branch. Although it resulted in a merge conflict too, I now have the updated files.

The last strange thing is the call to http://vvv.test/. It still displays the old version number 3.8.1 even after restarting vagrant.

Many thanks for your fast help. When working only every some years with that stuff, it is easy to get lost.

@tomjn
Copy link
Member

tomjn commented Jan 11, 2025

May be I've made a mistake when I created a local 'stable' branch and did pull into it ('git pull origin stable').

Yeah this doesn't seem great as it probably branched off of master which has a different history from github ( hence the conflicts, trying to merge 2 conflicting timelines and it doesn't know how so it's asking you instead ). I'd avoid these extra commands and I'd also mention them as they definitely matter.

What I'd do is this:

Abort any merges:

git merge --abort

checkout master:

git checkout master

Delete the local stable branch:

git branch -d stable

Fetch remote changes and checkout the stable branch

git fetch origin
git checkout stable
git pull

Then reprovision

vagrant up --provision

Then you should be on the latest version.


Note that in the beginning you could have done this:

git stash                  # stash your vagrant file changes
git checkout stable        # switch to the stable branch
git pull                   # grab the latest version of stable
git stash pop              # restore your vagrant file changes
vagrant up --provision

And if you had not modified the vagrant file it would be this:

git checkout stable
git pull
vagrant up --provision

Though you should not have needed to remove goodhosts.

Whatever you do:

  • don't create new branches
  • don't commit custom changes you made
  • don't try to resolve merge commits or do merges

All of these things hurt rather than help by taking you further away from what GitHub has, and introducing new differences that have to be undone. The goal isn't to shut up git, it's to make your copy of things identical to GitHub.

@tomjn
Copy link
Member

tomjn commented Jan 11, 2025

Just to clarify what your current problem is, by making new commits and a new branch you've created an alternate timeline that's branched off in its own direction by making new commits and new branches. That's why git is complaining about merge conflicts and resolution. That's also why my comment above deletes your branch and tries to reset it back to what is considered canonical.

@jotazzu
Copy link
Author

jotazzu commented Jan 13, 2025

Thank you for your directions. After executing the commands it looked quite well. But I decided to stop before the last vagrant up --provision and update Vagrant too. Now Vagrant has a dependency conflict. vagrant status gives the error message:

Error message given during initialization: Unable to resolve dependency: user requested 'vagrant-goodhosts (= 1.1.3)'

During a vagrant plugin --reinstall the output stated that it installed plugin 'vagrant-goodhosts (1.1.7)':

Vagrant will now attempt to reinstall user plugins that were removed.
Installing the 'vagrant-goodhosts' plugin. This can take a few minutes...
Installed the plugin 'vagrant-goodhosts (1.1.7)'!
Installing the 'vagrant-hostsupdater' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostsupdater (1.2.4)'!
Installing the 'vagrant-omnibus' plugin. This can take a few minutes...
Installed the plugin 'vagrant-omnibus (1.5.0)'!

So there seems to be a version mismatch for 'vagrant-goodhosts'. Do you have any idea how to solve that?

@tomjn
Copy link
Member

tomjn commented Jan 14, 2025

Add --local to the end of the reinstall command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants