0

This is not a duplicate of any current similar questions. I should know, I've read most of them. See below for why.

I must have read from top-to-bottom more than twenty articles about Git and Wordpress in the last 24 hours, along with all the relevant questions and answers on this Stack site, but most are either too specific (and therefore outdated) to be still relevant or they're concerned with taking a site from local to live rather than the other way around. Most importantly, not a single one includes information on what commands are actually needed for the process, which is a necessity when it comes to something as unintuitive as version control tools are.

Context

I have a site that I developed locally with XAMPP. I then used FTP and the Duplicator plugin to upload the site and database to a shared server. I've been using FTP to make changes since then, and I'd now like to incorporate Git into my workflow to make things more productive/natural. The goal is to be able to transfer the site between my local development server and the production server - without Github or another repository service in between.

However, even as someone with lots of CLI experience, after all the articles I've read and after also having scoured through man git and man gittutorial, I'm still very confused about how to use Git to do what I'm trying to do here.

What I'm Asking For

For example, I know that when I'm making changes locally I do git commit and then git push to push those changes to the live server, but how do I firstly download the contents of my live server to start working with it locally in Git - do I do git clone or do I do:

git init
git add .
git pull  

What about .gitignore? I have this sample file to tell me what should go in it, but at which point in this whole process do I create it? And what about the database? I already have a local one setup due to my previous local development environment, so is it still advised to replace that every time with the live one using a tool like Duplicator?

Git as a tool is very, very confusing to someone new to it, and doubly so when you have to take Wordpress into account, so I'm hoping that someone with the experience will be able to distil this stuff into something resembling a guide that tells me what commands I need to run to get my live site to my machine and then up-and-running with Git, as well as to detail any Wordpress-specific caveats.

Thank you in advance, such an answer would be much appreciated, and as someone with the CLI experience I have, I know that I can't be the only beginner Wordpress developer struggling to understand how to do this, so I don't doubt that such an answer would be useful to many other Wordpress/Git novices.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.