• Document Up to Date
  • Updated On 4.0.0

Git

The Git under projectTools allows the user to perform Git operations such as viewing remote repositories linked to the project and options to pull and push to the listed remote repositories. It also allows the user to add a remote repository to the project.

Below, we have a site mysweetdotcom with a link to a remote repository in GitHub:

Developer How-Tos - Pushing and Pulling from the Remote Repository

Add a Repository

To add a remote repository for your site, click on the New Remote button. A Create Repository dialog will open where you’ll need to fill in the required information then click on the Create button and you should see the new repository added in the Remote Repositories

Git - New Repository :align: center

Note

For more information on errors that a user may encounter when using ssh keys with CrafterCMS, see Troubleshooting SSH Key Issues

Pull from Repository

To get updates from the remote repositories, click on the down arrow next to the remote repository you would like to pull changes from

Git - Pull from Remote Repository

You will then be given some options when Studio pulls from the remote repository:

Git - Pull from Remote Repository Options

  • Accept Ours: Accept the local’s version of the site and overwrite the remote version if different

  • Accept Theirs: Accept the remote’s version of the site and overwrite the local version if different

  • None: Studio will try to merge the remote version with the local version

Successful Pull From Repository

Since 4.0.0

After making your selection, a notification at the bottom left of the screen will appear notifying the user of the successful pull, along with the merge commit id being copied to the clipboard and an option to publish it:

Git - Pull Successful Notification

If the user opts to publish the commit id from the successful pull, open Publishing under projectTools, then scroll down to the Publish on Demand section and select the publish by tags/commit id radio button, then pasting the commit id copied to the clipboard from the successful pull.

Another way of publishing the commitd id from the successful pull is to click Yes on the notification on the bottom left, then the Publish Commit dialog will open

Git - Publish Commit Id from Successful Pull

Conflict Resolution

When performing a pull from remote repository, Git is usually able to merge changes from the remote repository to your local files. Sometimes, a line you edited in a file may have also been edited on the remote repository which will result in a merge conflict when you pull from the remote repository. In this case, you will have to step in and tell Git what to do. Crafter Studio supports resolving the conflict from the Git dashboard.

Note

Remember not to use Studio as a git merge and conflict resolution platform. All merge conflicts should be resolved upstream before getting pulled into Studio.

When you perform a pull from repository, and there’s a conflict between your local files and the remote repository files, the message Pull from remote repository resulted in conflict will appear on the bottom left of the screen:

Git - Pull from Remote Repository Error

After the conflict message appears on the bottom left, to resolve the conflict, click on the Repository Status tab. Here, you will then be presented with options on how to resolve the conflict

Git - Pull from Remote Repository Error Resolution Screen

To cancel the pull operation, click on the Revert All button:

Git - Cancel Pull From Remote Repository

To resolve the conflict, you are given two options:

  • Accept Remote: accept the changes from the remote repository and discard your local changes

    Git - Pull from Remote Repository Conflict Resolution Accept Remote

  • Keep Local: keep your local changes and discard changes from the remote repository

    Git - Pull from Remote Repository Conflict Resolution Keep Local

  • Diff: let’s you view the differences between your local files and the files in the remote repository. Crafter Studio let’s you view the differences a couple of ways:

    Git - Pull from Remote Repository Conflict Resolution Diff Stacked

    Git - Pull from Remote Repository Conflict Resolution Diff Split

Select the appropriate button for your case, Keep Local or Accept Remote then click on Confirm. You will then be directed to commit the changes done to your local or cancel the pull operation.

Git - Pull from Remote Repository Conflict Resolution

When committing your changes, you will then be asked to supply a message for the repository history log then click on the Commit Resolution button and you’re done resolving the conflict

Git - Pull from Remote Repository Conflict Resolution Commit

Push to Repository

To push your changes in Studio to a remote repository, click on the up arrow next to the remote repository you would like to push changes to

Remote Repositories - Push to Remote Repository :align: center

In the Push dialog, select the branch in the remote repository you’d like to push changes to

Remote Repositories - Push to Remote Repository :align: center