Jump to content

How to use Git to merge updates with edited core files


Dirty Butter

Recommended Posts

The Pro-Git book / PDF is freely available. That's how I learned to use git (that and LOTS of practice and Googling).

To set up a basic repo is simple if you know how to open a command window or install SourceTree, but it can be a lot to process at first because of the multiple tools involved:

  1. Download the git utility / install a program like SourceTree that comes with it
  2. Run 'git init' in an empty directory to create the repository (or create a new repo using SourceTree's interface)
  3. Copy all your files into that directory - I recommend adding the images and cache directories to the .gitignore file (or, again, ignore them from the interface)
  4. 'git add --all' or add all files from within SourceTree
  5. 'git commit' then type a message like 'initial commit' - you might be in Vim editor, so you'll want to become familiar with the basic commands
  6. Now you're basically done

Once you have the first commit to your repository, you can set up a Github (only recommended if you want your source to be public or you are willing to pay for private repositories) or Bitbucket (allows up to 5 free private repositories) account and push your code there so you have an online 'backup'. It also allows you to collaborate, e.g. if you have a team of coders / designers.

From this point forward, any changes you make will be immediately apparent from within SourceTree or by running 'git diff' against any commit or branch. Make small commits containing a single feature / changeset at a time, get familiar with branching and the Git Workflow, and your life will be good.

Now you have two options to update your code:

  1. NOT RECOMMENDED WAY: Simply copy the latest CubeCart version files into your directory (make sure any uncommitted changes are stashed or committed first!) and you will see what has changed. You'll want to check every single file and every single line for conflicts and manually resolve them.
  2. RECOMMENDED WAY: This way is a little more to chew, but it is far superior. Instead of creating a completely new project like in step #2 above, fork the actual CubeCart repository on Github, then paste YOUR changes on top of it. Add the original repo as an upstream remote, and you can pull the latest changes into your branch at any time and Git will inform you of any conflicts automatically.

I know it can be pretty daunting, but the results are awesome. You can make experimental changes on a new branch - if it doesn't work out, just throw it away and you've still got your original code in working order. If it does work out, just merge it in. Did it introduce a serious bug? Checkout the last known bug-free version and put that on your live site, then checkout the buggy one locally while you sort out what happened.

If you're doing any amount of modifications to the core files, this is, in my opinion, the only way to do it while keeping your sanity. Good luck.

Link to comment
Share on other sites

OH MY!!! Well, hopefully this will be helpful to some - but not me at this stage of my abilities.

@bsandall Thank you for taking the time to provide this info and PDF link.

Took a quick look at the PDF Table of Contents and the Install section. What is your opinion of GitHub for Windows? I'm on Windows 10.

Edited by Dirty Butter
Link to comment
Share on other sites

When I have more time, I'll update the earlier post to be more helpful, i.e. full setup instructions using SourceTree, which is the only application I would recommend both for beginners and more advanced users alike. The interface is 100x more intuitive and useful than the Github app for Windows, not even exaggerating (okay, maybe a little...).

Note that you can use SourceTree with repositories hosted on Github and vice versa, the Github app for repos on Bitbucket, and you can manage repos on both from the same application at the same time. Pretty nifty.

Link to comment
Share on other sites

OK - I see that SourceTree can be used on Windows. I have been waiting for our Christmas season to be past before doing the 6.0.8 upgrade on our toy store, but I've already created what I hope is a correctly merged 6.0.8 version ready for it. That will give me some time to play with Git before I attempt 6.0.9 when it's available. That's basically what our dirtybutterestates.com site is for anyway - a place for me to learn and make my mistakes without hurting our main business.

Link to comment
Share on other sites

It's always good to have a test area ;)

Personally, I prefer to keep my testing mostly offline, so I use a local WAMP stack going with multiple test sites (various projects, not all CubeCart) on it each in a different directory, where each test site has its own git repo (most completely local, too - no online version of the repo).

This way, I can catch most of my issues before they ever go live, as well as continue to work without internet - our internet connection is pretty bad, so that last point is especially important for me.

Anyway, sounds like you are well on your way with Git already. Once you start thinking in terms of the git workflow, life gets much easier, but be prepared: I fought with Git plenty my first year, though I didn't use it much that first year, either. It can be very frustrating, but if you stick with it, it really pays off.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...