
Git Commands for Students: From First Commit to GitHub Pull Request
Dr. Himanshu Verma
Associate Professor & HOD, Computer Science & Engineering, Haridwar University
Table of Contents
- 1. What Git and Version Control Mean for Students
- 2. Git and GitHub: Understanding the Difference
- 3. Setting Up Git and Creating Your First Repository
- 4. Understanding the Four Stages of Git
- 5. Making Your First Commit with Essential Git Commands
- 6. Creating Branches for Independent Project Work
- 7. Pushing and Pulling Changes Between Git and GitHub
- 8. Creating a GitHub Pull Request
- 9. Handling Merge Conflicts and Common Beginner Mistakes
- 10. FAQs
- 11. Building Good Version Control Habits
Git is one of the tools I recommend students learn before they begin serious software projects. It helps developers track changes, recover earlier versions of code and work on shared projects without relying on manually exchanging files. Yet many beginners learn commands such as git add, git commit and git push without understanding how they connect.
In this guide, I will take you through Git commands for students using a practical example: a small student project developed with classmates. We will create a repository, make the first commit, work on a separate branch, push changes to GitHub and submit a pull request.
The aim is not to memorise every Git command. It is to understand a workflow you can use in your coursework, projects and collaborative development.
1. What Git and Version Control Mean for Students
Version control is a way to record changes made to files over time. If a new feature breaks your project, you can inspect earlier versions and recover the work you need.
Git is a distributed version control system. Each developer can maintain a local repository containing project files and their version history. This means you can commit changes on your computer without needing an internet connection.
Consider a team building a student attendance application. One student works on the login page, another develops the attendance module, and a third updates the documentation. Git helps the team manage these changes systematically.
I often explain the value of version control this way: a project should have a record of how it developed, not just a folder containing its latest files.
2. Git and GitHub: Understanding the Difference
Git and GitHub are related, but they are not the same.
You can use Git without GitHub. However, when students work in teams, GitHub provides a convenient place to share repositories and review proposed changes. GitHub's official introduction to Git explains the relationship between the two.
3. Setting Up Git and Creating Your First Repository
Before writing commands, install Git on your computer. You can download it from the official Git website.
After installation, open Git Bash or your terminal and configure your identity:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Git uses this information to identify the author of your commits. Use an email address associated with your GitHub account if you want your commits to be linked to that account.
Now create a folder for your student project:
mkdir student-attendance-app
cd student-attendance-app
git init
The git init command creates a new local Git repository in the folder. Create a file named README.md and add a short project description.
You can check the repository's current state with:
git status
This command tells you which files are untracked, modified or staged. It is one of the most useful Git commands for beginners because it shows what Git sees before you save a commit.
4. Understanding the Four Stages of Git
To use Git confidently, understand how a change moves through its workflow.
The distinction between staging and committing is important. Editing a file does not automatically include it in a commit. You first select the changes with git add, then save them with git commit. This separation gives you control over which changes belong together in the project history.
5. Making Your First Commit with Essential Git Commands
A commit is a recorded snapshot of the staged changes. For our attendance application, suppose you have created the initial README file. Run:
git status
git add README.md
git status
git commit -m "Add project README"
git log --oneline
Here is what each command does:
git statuschecks the current state of your files.git add README.mdstages the README file.git commit -m "Add project README"records the staged change with a descriptive message.git log --onelinedisplays a compact history of commits.
You can stage all changed files in the current directory using:
git add .
However, I advise beginners to check git status before staging everything. This helps prevent temporary files, generated files or unrelated changes from entering a commit.
A useful commit message describes the change, not simply the activity. For example, Add login form validation is more informative than Updated files.
Connecting Your Main Branch to GitHub
Before creating a feature branch, connect your main branch to GitHub. Create an empty repository on GitHub, then run:
git branch -M main
git remote add origin https://github.com/USERNAME/student-attendance-app.git
git push -u origin main
Replace USERNAME with your GitHub username. These commands rename the current default branch to main, connect your local repository to GitHub and push the initial README commit.
6. Creating Branches for Independent Project Work
A branch lets you develop a feature separately from the main line of development. It is particularly useful when several students contribute to the same project.
Suppose the main application is working, and you want to develop a new login page. Create a separate branch:
git switch -c feature/login-page
The -c option creates the branch and switches you to it. You can confirm your current branch with:
git branch
Now edit the login page, stage the changes and commit them:
git add .
git commit -m "Add login page"
Your work is recorded on feature/login-page, leaving the main branch unchanged until the changes are integrated.
For beginners using older Git installations, git checkout -b feature/login-page is another way to create and switch to a branch. The git switch command is more focused on branch switching.
7. Pushing and Pulling Changes Between Git and GitHub
Once your local repository is connected to GitHub, you can share new commits and synchronise changes between the two repositories.
After committing your login-page work on the feature/login-page branch, push that branch to GitHub:
git push -u origin feature/login-page
This uploads your feature branch and establishes its upstream tracking relationship with the remote repository.
Three commands are particularly useful when working with remote repositories:
Do not confuse git pull with a pull request. A pull command synchronises repository changes. A pull request asks collaborators to review and potentially merge proposed changes.
8. Creating a GitHub Pull Request
A pull request, commonly called a PR, is a way to propose changes from one branch to another on GitHub.
Continue with our attendance application example. You have developed the login page on feature/login-page and committed the changes locally. Push the branch:
git push -u origin feature/login-page
Now open the repository on GitHub:
- Select the pushed
feature/login-pagebranch. - Choose the option to create a pull request.
- Set the base branch to
mainand the compare branch tofeature/login-page. - Add a clear title, such as Add login page.
- Describe what changed and what the reviewer should check.
- Create the pull request.
A useful PR description might explain that the login form has been added, identify the files changed and mention any testing completed.
The reviewer can inspect the differences, leave comments, request changes or approve the work. Once the team is satisfied, the changes can be merged into main. GitHub's pull request documentation explains how to create, review and merge pull requests.
9. Handling Merge Conflicts and Common Beginner Mistakes
A merge conflict occurs when Git cannot automatically combine changes, often because different branches have modified the same part of a file. For example, two students might edit the same heading in the application's README. Git may need someone to decide which version to keep.
When a conflict occurs:
- Open the file identified by Git.
- Find the conflict markers and review both versions.
- Edit the file to retain the intended content.
- Remove the conflict markers.
- Stage the resolved file using
git add. - Complete the merge or continue the operation as Git instructs.
Other mistakes are easier to prevent:
Students should also avoid committing passwords, API keys or private configuration files to a shared repository.
10. FAQs
1. Is Git necessary for computer science students?
Git is a valuable tool for students who write code, build projects or collaborate with other developers. It helps maintain project history and manage changes.
2. What are the five basic Git commands beginners should learn?
Start with git init, git status, git add, git commit and git push. These introduce repository creation, status checking, staging, committing and sharing changes.
3. What is the difference between Git and GitHub?
Git is a distributed version control system that tracks changes. GitHub is an online platform that hosts Git repositories and supports collaboration through features such as pull requests.
4. Should I commit or push first?
Commit first. A commit records staged changes in your local repository. Push then uploads those commits to the remote repository.
5. What is the difference between git pull and a pull request?
git pull fetches and integrates remote changes into your current branch. A pull request is a GitHub collaboration feature used to propose changes for review and merging.
6. Can two students work on the same GitHub project?
Yes. They can create separate branches, commit their work and push their branches to the shared repository. Pull requests allow the team to review changes before merging them.
7. Is GitHub Desktop suitable for beginners?
Yes. GitHub Desktop provides a graphical interface for common Git operations. Students can use it to understand repository changes and commits before becoming comfortable with terminal commands.
11. Building Good Version Control Habits
Learning Git commands is only the starting point. The real benefit comes when students use version control consistently while developing projects.
I recommend beginning with a small repository, making focused commits and creating a branch whenever you work on a separate feature. Practise reviewing changes before merging them. These habits make collaborative development easier to understand and maintain.
Students following HU's semester-wise coding practice roadmap for placements can include Git practice alongside programming and DSA preparation. Those developing portfolio projects can also explore final-year project ideas for CSE and AI/ML students and learn more about the computing programmes offered at Haridwar University's Roorkee College of Smart Computing.
My advice is straightforward: do not wait until a large team project to start using Git. Create a repository for your next programming assignment, record your progress through meaningful commits and practise submitting a pull request. Understanding that complete workflow will serve you far beyond your first coding exercise.
Build Industry-Ready Software Engineering Skills at Haridwar University
Master version control, collaborative coding, and modern software workflows through hands-on projects and placement-focused computing programmes.

