How To Adapt Your Current Project To Git

If you started modifying your platform's core files and don't want to use vMod for virtually modifying it. Then you probably think upgrading the platform is hundreds of hours of work. That does not need to be the case.

Adapt your current platform to Git for easily pulling future updates. Here is what to do:

  1. Sign in to your favourite Git repository provider (e.g. GitHub or BitBucket) and create a new Git repository.

  2. Use your Terminal or Git Bash to initialize your Git project and configure it for repositories. (We are assuming you have Git installed on your computer e.g. )

# Navigate to an empty project folder
cd "C:\\path\\to\\myproject\\"

# Make this directory a Git project
git init

# Set your Github or Bitbucket repository as "origin"
git remote add origin https://github.com/username/repo.git

# Make your main repository branch the default upstream for pushing content.
git push --set-upstream origin master

# Add LiteCart's repository as "litecart"
git remote add litecart https://github.com/litecart/litecart.git

# Retrieve some information from the LiteCart repository
git fetch litecart

# Reset your project back to a certain LiteCart version number (stated by it's tagname) e.g. 2.1.6.
#For the very latest commit simply ommit the version number
git reset --hard 2.1.6 litecart/master

# Copy your modified LiteCart platform into your project folder. Replace all existing files.
xcopy "C:\\path\\to\\your\\litecart\\folder" "C:\\path\\to\\myproject\\" /E /H /Y

# Show all changes
git status

# Commit all changes
git commit -m "My big initial commit"

# Push your commit(s) to your repository named origin that has a branch named master.
git push origin master
  1. Now begins the fun. Pull all updates from Github.
# Pull all updates from the Github repository we called litecar
git pull litecart
  1. Solve any merge conflicts. (This guide will not teach you how to solve conflicts. But we recommend using TortoiseGit Resolve)

  2. Use your browser to navigate to the installation folder and run the upgrade script. This will perform all changes necessary to update files and database.

    Example: https://localhost/litecart/install/upgrade.php

  3. After the upgrade, make sure your platform is running fine. Use your web browser to access it:

    Example: https://localhost/litecart/

  4. Finally commit all changes and push them to your repository:

# Commit all changes
git commit -m "My commit message"

# Push commit to repository
git push origin master
  1. All done! You should now be running the latest update of LiteCart merged with all your modifications.

Now you can use Git to commit all your new features and updates. Next time you want to pull an update, go back to step 3.

Sourcetree is a great GUI tool for playing with your Git projects. It's awesome, just like LiteCart! ;)

See Also

Revisions

Top Editors
Recently Edited Articles