Guide to Git: Uploading your Folders to GitHub or Bitbucket

Guide to Git: Uploading your Folders to GitHub or Bitbucket

In today’s guide, we are going to bring you through the series of commands you need to upload your folder or files to GitHub or Bitbucket.

Guide Assumptions
– You are using Local by Flywheel, and have created a local site. A guide for doing this will be coming soon.
– You have created a repo on your Bitbucket or GitHub account. A guide for doing this will be coming soon.

Our Tech
MacBook Pro 2017

We are starting a new web project for a client, which Michéal and I will be working on. As I’m in Dublin and Michéal is in Berlin, collaboration could pose a few issues, none more so than editing of files. This is why we use Bitbucket for version control, and to track changes we are making.

Today, I started off by creating a new instance of a WordPress site on my local directory using Flywheel. It was quick and easy to do, and something we will do a guide on soon.

When the local site is created on our machine, it needs to be uploaded to Bitbucket so we can make changes to various components. So to do this, we need a series of commands, and a series of steps. We are going to assume you are using the same tech as us, if you are using something different and having an issue, leave a comment below.

Step 1. Go to the source folder

To start, we need to open the folder in Terminal for git. In Finder, this folder will be under:
Mac HD >> Users >> Your User Folder >> Local Sites.

To get to this folder using Terminal, you must type the following

    cd ~/Local\ Sites/

This will bring to your local directory. To see the sites already here, type “ls” which will list your local sites. We have been very creative altogether, and called our website WP-Example. To access this folder, you would enter

    cd wp-example

That wasn't too hard, and by playing with commands in Terminal, you'll get more confident. Again we type "ls" to see the folders in the directory. At this stage you want to go to the "app" folder, and following that, to the "pubic" folder
    cd app
    cd public

You are now in the WordPress root folder. Most of the files here you won’t need to edit. The folder you will be concentrating on is WP-Content.

    cd wp-content

And that’s it, you are now in the WP-Content Folder using Terminal.

For those of you who are used to Git, this could have been done using a single line, once you know the directory you are going towards

    cd ~/Local\ Sites/wp-example/app/public/wp-content

Step 2: Uploading to Git

As mentioned above, we are making a couple of assumptions for these steps. You have created a repo on your Bitbucket or GitHub account, and added your SSH key to your Bitbucket account. Guides on all these steps will be coming soon.

We feel it is best to just upload the theme files, rather than all the contents of the wp-content folder. For that reason, we think its best to go down one more layer to

    cd themes.

We now create a git repo

     git init

Lets now add all the theme files to that repo

     git add -A

Now lets commit the files to the repo. Its also very important to add a comment here when uploading your files.

     git commit -m "Uploading theme files"

Now add your Bitbucket repo

     git remote add origin your-bitbucket-link

And finally, add upload the files to your repo

     git push -u origin master

And that’s it, you’ve just uploaded all your files to your BitBucket/ GitHub repo!!

No Comments

Post A Comment