Plugins added to live WordPress site and not Git repo (WP-Engine)

I have picked up a project at a new company and the client has manually added plugins and other files directly to their live WordPress site and not to the git repo. Our workflow is to code locally then use the command line to push changes to the site which is hosted on WP-Engine. This is the command git push main main which pushes the branch main to the live site. Here is the error given ! [rejected] main -> main (non-fast-forward) error: failed to push some refs to 'git.wpengine.com:newnetworkrail.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. I am struggling to figure out the best way of handling this. I need to get the files the client has added off of the live site and add them to the repo so the 2 match up but I've no idea how to go about doing this - for example how do I see what the conflict is. Any help would be hugely appriciated.

Comment (1)

Jese Leos

August 28, 2024

Verified user

Putting aside why the developer and client are using the same branch (maybe you’re helping to maintain the website?), if that’s the case, why do you still need to "manually" add them to the repo to keep things in sync? Git already manages version control, which keeps the code unified—that’s also why this error happens. The above error occurred because the local main branch is currently behind the remote main branch on WP-Engine, so the commit was rejected. In your case, If there already have some changes in the local repository, you could: # Stash the current changes $ git stash # Sync with the remote WP-Engine $ git pull main main # Apply the stashed changes $ git stash pop # Add changes $ git add <filename-that-you-want-to-commit> # Commit $ git commit -m "feat: modify files" # Push $ git push main main Otherwise, you just need sync to the remote branch, then do other actions: $ git pull main main Can also check out this guide on Git version control for more information on usage and concepts, which might be helpful.

You’ll be in good company