Close this search box.

Re-Exploring the Git Branching Model for the Classroom

In a session from the 2021 GitKon Git conference, Roy Vanegas, professor at the University of Hartford, shared how he uses Git and GitHub in the classroom. Using Git, Roy has successfully developed replicable Git branching models for classroom-friendly workflows, grading, and methods for distributing assignments. 

These strategies can be used by teachers in a more traditional classroom setting, but also by managers for professional growth, leaders of technology interest groups for knowledge sharing, and more. 

GitKraken offers our GitKraken Client Pro FREE for teachers through the GitHub Teacher Toolbox! PS: students also get free resources!

Get GitKraken Free for Teachers

Sharing Assignments with Git and GitHub

Creating a “Don’t Work Here” Main Git Branch

If you want to share assignments with students using Git, start by creating a default local Git repository. Next, create a Git branch called “Don’t Work Here” and push the branch to your shared repository on GitHub. 

You will need to make the new “Don’t Work Here” branch your main branch. To do this in GitHub, you can select “Settings” -> “Branches” -> “Main” -> then select “DON’T WORK HERE”-> “Update”. 

Watch this clip to follow along with Roy and see how he create his “Don’t Work Here” branch and sets it as default.

Ensuring that your main branch is titled “Don’t Work Here” simply ensures that students don’t accidentally start working in the main branch. Eventually, each student will have their own Git branch with their name on it, thus mitigating the risk of breaking other students’ code. 

After you make the “DON’T WORK HERE” branch the new “main” branch, delete the original main branch. You can do this this by running the following: 

git branch -d main -> git push origin --delete main -> git push origin --delete main

delete original main branch

Alternatively, you could rename the main branch instead of creating a new one. Regardless of how you accomplish this, the goal is to have one main branch that clearly directs students not to make any changes inside it. 

Creating a Git Branch for Each Student

Next, use scripts to gather student data including first name, last name, and GitHub username. This will allow you to create a branch for each student. Using this information to create their branch will help avoid any confusion in the event that two students share the same name. 

Example of a student branch name: linus-torvalds-linux-inventor

create new git branch for each student

The image above is an example of a list of fictitious students, each with their own branch. 

Finally, instruct your students to go online, access the project, and fork the branch. After each student has forked the branch into their GitHub account, they can get to work! 

Submitting Work with Git and GitHub

When giving out assignments, you should give specific instructions requiring students to turn in the project as one main file. If a student plans on submitting additional files, those files must be dependencies of the main file. This streamlines the process of navigating through each student submission and makes grading student’s submissions much faster. 

When students are ready to submit their work, they submit a GitHub pull request. From the teacher’s perspective, this makes it very easy to navigate through and analyze all the branches to make sure they’re correct. Once accuracy has been verified, teachers can accept the pull request into the shared GitHub repository. 

One added benefit to having all student projects in one shared repository is the ability to conveniently show examples of student work during class. Instead of having each student hook up their computer individually, you’re able to present as many projects as necessary from the same machine.

Collaboration in a Git Classroom

Another unique benefit to a Git classroom strategy is the ability for students to work collaboratively. While students must each turn in their own unique assignment, they are allowed to look at the ungraded work from other classmates’ branches for inspiration. This does come with risk, as teachers must trust their students to practice the honor system, or have systems in place to make sure nobody abuses the system and directly copies work. 

The ability to reference the work of peers and see how others are solving problems is a huge benefit to a Git classroom workflow. Not only is this a beneficial classroom practice, this workflow also mimics how real-world developers interact with their teams, which makes it an ideal practice that prepares them for the workforce. 

Detecting Cheating with Git Diff

Unfortunately, cheating and academic dishonesty occur in many classrooms, requiring teachers to create safeguards and processes to detect such behavior. When grading student projects using Git and GitHub, you can run a script designed to detect similarities between branches. 

To compare branches, run git diff followed by each branch name, one for each student you wish to evaluate. The command returns all the differences between projects, and allows instructors to quickly determine if any cheating has occurred. 

If the command reveals a variety of differences, it’s likely no cheating occured, but if the command returns no differences, clearly one or more of the students with matching projects have cheated. This process is quick, convenient, and allows the instructor to clearly identify whether or not cheating has happened.

Example of Unique Work

Example of Unique Work

Example of Cheating Detected - No Diff

Example of Cheating Detected – No Diff

The diff tool in GitKraken Client enables you to make more informed decisions, so you can perform advanced Git actions, like rebase, with more power and less risk.

Sharing Examples with Git and GitHub

Showing and sharing examples in class is one of the most compelling reasons to start using this Git classroom workflow. Imagine this: upon coming to class each day, students launch GitHub Desktop, or another Git client of choice like GitKraken Client, on their machines and open up the example repository that correlates with the day’s lecture. Whenever the teacher pushes new changes to the example repo, the students can perform a Git pull and immediately see the example on their computers. 

This process of sharing examples of code has some major advantages. Instead of trying to furiously write out intricate lines of code and complex commands, students can view the code in real time. This workflow also allows instructors to reinforce learning principles by allowing students to add to the example by making Git commits of their own. 

To recap, students should perform the following steps upon arriving to class:  

  1. Launch their Git client, like GitKraken Client 
  2. Launch their code editor 
  3. Update their copy of the examples by pulling, fetching, and refreshing

This workflow’s greatest strength is the added time it gives students to take notes about the code and about the principles behind it rather than trying to follow along and copy random code down word for word. 

Easily Archive Repositories for Future Use

A big pro of using this Git workflow is how convenient it is to archive repositories. Once an instructor finishes a class, they can mark the repository as private and leave it alone until they need it again for a future class, or need to reference it for some other purpose. This workflow creates a record for everything. Every lecture, every example, and every other resource used by the instructor can be easily saved and referenced in the future. 

In fact, Roy was recently contacted by a professor at another university to help identify a possible instance of academic dishonesty committed by a past student. Roy was able to navigate through old grades and assignments and collect the information the other professor had requested very quickly, even though the student hadn’t been in his class for quite some time. 

Overcoming the Git Learning Curve

The learning curve with Git can be steep, and can be especially difficult if a student has never worked with similar technology. From an instructor’s perspective, it can be quite challenging to teach. While you can conduct in-depth lectures, at its root, Git can be a confusing system to learn.

It’s important to recognize, the Git classroom workflow is a totally different way of using Git than anything you would commonly find in the private sector. Even experienced Git users can struggle at first just getting used to the unique project design. 

But overtime, and with enough helpful resources, you and your students can overcome the challenges of learning Git. 

The learning curve for Git can be steep, but taking the time to understand Git concepts will serve you well in years to come. GitKraken’s learning resources will help you and your team understand fundamentals and advanced actions so you can have more confidence in your workflow.

Learn Git with GitKraken

Timestamps on Work

Another pro associated with using Git in the classroom is the ability to see exactly when students have worked on, finished, and submitted assignments through timestamps. Let’s say, for example, you have a policy of not accepting any late work, but a student insists they couldn’t submit for some reason. 

You can easily look at their system and run a handful of commands like git log to see when the last commit was performed and compare that information with the assigned due date. Having timestamps on work can be helpful in a variety of complex scenarios that inevitably come up when working with students. 

Searching Through Large Projects in Git Can Be Complex

There are some drawbacks to using Git in the classroom.  For one thing, it can be hard to find files students have turned in.  If you are on your local operating system and use the built-in search for a particular file, you need to be sure which branch you’re actively on. 

Searching for both files and branches at the same time can get complicated rather quickly. This is why having a proficient understanding of how to use the Git command line is required to embrace this approach, which can be overwhelming for folks who are new to Git. 

Access to Course Material with Git and GitHub

In the event that a student misses class, they will still have access to the code and course materials they missed. They can simply go to the class repository on GitHub, update their local repository, and any code that was shared that day is now available to them locally on their machine. 

While each instructor may have a varied policy regarding attendance, at least using this model students have the ability to stay caught up on course material. 

Implementing a Git Classroom Model

To recap, the Git classroom workflow follows this outline: 

  1. Assign each student their own Git branch to work in
  2. Instructors show examples using an example GitHub repo during class time
  3. Students submit the assignment by submitting a GitHub pull request
  4. Students collaborate and learn from one another by viewing each other’s projects 
  5. The instructor grades and compares submissions with Git and GitHub

While it can be a difficult process to implement at first with Git’s intense learning curve, if utilized correctly, this workflow can become very effective for both students and teachers. Allowing students to view examples from their peers and instructors outside of class ensures that time in the classroom is used to ask questions and dive deeper into the material, rather than simply capture surface level notes.  Ultimately, using a Git model in the classroom creates an immersive, hands-on environment that allows students to really learn Git.

If you’re looking for more ways to teach students how to use Git, try out GitKraken Client. This legendary Git tool makes learning Git simple with its beautiful visuals, intuitive actions, and team features – plus, check out the free resources for students and teachers. 👀

Make Git Easier, Safer & more Powerful

With the #1 Git GUI + Git Enhanced CLI

Visual Studio Code is required to install GitLens.

Don’t have Visual Studio Code? Get it now.