Using Git via the editor

Using Git via the editor

> Editor in depth

Introduction

What is Git?

Git (pronounced with a hard "g", to rhyme with "bit") is a code versioning system that is commonly used in software projects. Among other things, it lets you:

A folder versioned by Git is called a repository (or _repo_ for short).

What is a forge?

While Git is a piece of software you can use locally (on your machine or in the Leek Wars editor), it can also interact with a software forge: a server that hosts Git repositories.

Leek Wars supports several forges. The simplest option is to pick one of these:

You can also use other forges based on GitLab, Bitbucket, Forgejo, Gitea or Gogs, for example framagit.org or gitea.com.

Using Git for an existing AI

First of all, the AI must be inside a folder, not at the root. Create a folder, right-click it and choose "Initialize Git repository". This folder will contain all the files tracked by Git.

A Git tab with a branch icon appears at the top of the file list (left-hand menu). Open it.

Making commits

("commit" is Git's word for saving a set of changes: you _commit_ them to the history)

At the top of the Git tab, use the drop-down selector to check that the right repository is selected (if you have several).

When files in the repository are modified, the changes appear in the Git tab. For now they are unstaged: think of them as a draft, not yet set in stone in the history.

When you want to record changes in the history, click the ➕ button to stage them. Sum up the changes in a few words in the "Commit message" field, and confirm.

Note: to see all the buttons of the Git tab, you may need to widen it by dragging its right edge to the right!

The history is a list of commits, each commit being a set of changes with a date and a message. The idea is to be able to find out when a given change was made, to go back in time, to group changes together so you don't end up with half-working code...

Connecting to a forge

Setup on the forge

Create an account on a Git forge and create an empty repository there. Find your repository's address, which should look like https://example.net/my-username/my-repo.git. It is the address of your repository's main page, with .git added at the end.

You then need to allow Leek Wars to access the repository. How you do this depends on the forge.

If you created a token, keep it somewhere safe so you don't lose it!

Setup on Leek Wars

At the bottom of the Git tab, click the cloud button, "Remote settings".

This is where you declare the remote repository (the remote): enter a name (for example origin), paste the repository URL and click the "Add" button. You must do this before you can push anything.

For authentication, choose your forge: GitHub, GitLab, Bitbucket or Forgejo.

Sending your commits to the server

For now, the commit history is only stored in Leek Wars. To send it to the forge, you push it with the ⬆ button at the very bottom of the Git tab.

Every time you want to send new commits, push again.

Other features

The editor and the Git tab also offer: