Git and Gitea lab: learn clone, commit and push on a Git server of your own
This lab gives each student their own Gitea, a small self-hosted Git server with a web interface like GitHub’s, holding a repository with two commits in it. From the terminal beside it they clone the repository, create a file, stage it, commit it and push it, then find their commit in the web interface.
There is no GitHub account to make and nothing to install, which is what makes it suitable for a first lesson on version control.
What students learn
The loop of version control: git config, git clone, git status, git add, git commit, git log and git push, and what each shows. They find their commit at the top of the history in a web interface, edit a file in the browser and pull it back down. Natural next lessons are a branch and a pull request, a conflict made by editing the same line in the browser and the terminal, and undoing with git revert.
Run it in your browser
The Gitea account is student with the password student, and the repository is student/hello-git.
- Open the Container page. Open Build on the bar and choose Run a container. Anybody may open it, and the Git lab and the SQL lab start with no account. Every other lab needs a free account: create one, sign in, then press Start.
- Find the lab. The Sample labs card lists every sample. Find Git with Gitea.
- Press Start. Start runs it as it is, in one press. Edit the file first opens the compose file so you can change it before you start.
- Open it. On the lab’s page, under In your browser, press Gitea and look at hello-git. In the terminal, git clone http://gitea:3000/student/hello-git.git: the terminal reaches Gitea by its service name. The README walks through every step.
The code on GitHub
One compose file; Gitea runs as an ordinary account and needs no extra permissions. It runs on your own machine too. Fork it to change the starting repository.
A basic lesson on this lab
Git Basics and Git Basics 2 are lessons worked in this lab, each step explained and with a Run button that types a command into the student’s terminal. In Git Basics they make a repository, a folder, a file and a first commit, and push it. In Git Basics 2 they work on a branch, push it, merge it with a pull request in Gitea and bring the merge back.
A free personal account is given them on the Basics module, which is on Home, every college can copy them from the Library’s Basics folder, and a new college opens with them in a module called Basics (Sample). They are deliberately small: they show a teacher what a lesson worked in a lab is, and the lab does the rest. Copy one into a module of your own to change it.
Set it as work
Ask students to push a commit that does something you name, and to hand in the history.
- Make the lab. In your module add a task and choose the Container lab card, then In a GitHub repository. Give https://github.com/mitsurutech/lab-git-gitea with the branch main. The compose file is the default, compose.yaml. Fork the repository first if you want to change it.
- Publish and try it. Publish pins the commit you were shown, so a later change in the repository does not alter a lab you have already set. Start your own copy first.
- Hand it out. Assign it like any task, with a due date if you want one, and say in the task what to do and what to hand in.
- Mark what is handed in. Open a student’s copy and the work they handed in, mark it, and send it back with a reason if it needs more.
Questions people ask
- Do students need a GitHub account?
- No. Each student’s lab starts its own Gitea, so they push to a Git server that belongs to their copy of the lab and exists nowhere else.
- Is the work kept between sessions?
- Yes. Gitea keeps its repositories and its database in a named volume that the platform saves, so what a student pushed is there next time.
- Which Git commands do students practise in the Gitea lab?
- The everyday loop: git config, git clone, git status, git add, git commit, git log and git push, and what each one shows. They then find their commit at the top of the history in Gitea’s web interface, signed in as student with the password student.