Git and GitHub in an IDE: From a Commit to a Pull Request
What a commit, a local repository and GitHub are. Add a test case to the team’s repository with IDE buttons: Clone, a new branch, Commit, Push, a Pull Request, review, Merge and Update Project.
About the product
Hi! Our team keeps test cases not in a spreadsheet but in a Git repository on GitHub, next to the code. That way you can see who changed what and when, and every change goes through review. Your task is to add a new test case: a sign-in lockout after three wrong passwords.
Sounds interesting! How do I do it?
Through a Pull Request, like everyone on the team. Kadri will show you the whole way: you will download the repository, create a branch, make a commit, send it to GitHub, open a Pull Request, go through review and merge the changes into main.
Hi! We’ll do everything in the IDE: with buttons, no commands. But first, the big picture: where the project lives and how your changes reach your teammates.
Hi, Kadri! How does it all work?
Everyone on the team has their own copy of the project on their computer, and the shared version lives on GitHub. Changes travel between them along the arrows:
Your computer
GitHub, the shared base
the version of the project the whole team seesPull Request · reviewTeammates
each has their own copyCommit
A save point, like in a game: a snapshot of the files with a description, the author and the time. You can go back to any commit, and you can always see who changed what.
Local repository
The project on your computer together with its whole commit history. A commit lands here first: teammates can’t see it, and you don’t need the internet for it.
GitHub, the shared base
The team’s remote repository; Git calls it origin. Push sends your commits there, pull brings your teammates’ commits from there. Pull Requests and reviews happen here too.
IDE
An IDE is a program for working with the project’s files. Git is built into it: buttons instead of commands, while the same Git commands run under the hood.
Let’s check. You’ve just made a commit. Where is it now?
Got it! What else will I meet along the way?
A few more words you’ll need today:
Glossary
clone— download a repository from GitHub to your computer. You do it once, when you start working on a projectbranch— a separate line of work. The main branch,main, is the checked version, and every task gets its own branchpush— send your commits to GitHubpull— bring new commits from GitHub. In the IDE this button is called Update ProjectPull Request (PR)— a request to merge your branch intomain: teammates review the changes before the merge
A teammate wants to see your commit. What do you do?
All clear! Opening the IDE.
Workspace
Step 1 · Cloning
First, let’s get the project onto your computer. To do that, you clone the repository: Git downloads all the files and the whole history from GitHub, and you get your own local repository.
How do I do that in the IDE?
In the GitHub window under the IDE, click the green Code button and copy the address. Then, on the IDE welcome screen, choose Get from VCS, check the address and click Clone.
Hint
Where to click:
GitHub: Code → ⧉ IDE: Get from VCS → Clone
The same in the terminal:
git clone https://github.com/bb-food/shop-tests.git
Working directory
Ticked for the commit
☑Local repository
CommitGitHub (origin)
PushIDEDevelopment environment
- Projects
- Customize
- Plugins
- Learn
Welcome to the IDE
Create a new project to start from scratch.
Open existing project from disk or version control.
Done! The IDE downloaded the project and opened it: the file tree is on the left, and the Git window with the commit history is at the bottom. In the diagram, the files appeared in the working directory, and the local repository has the main branch with two commits. Look at the Console tab at the bottom: the IDE ran the same git clone command people type in the terminal.
What does Clone do?
Can I change the file now?
Step 2 · A new branch
Almost. main holds the checked version that the whole team uses, so nobody writes to it directly. Every task gets its own branch: you can work there calmly without getting in anyone’s way.
How do I create a branch?
Click the main branch name in the IDE top bar and choose New Branch… Enter the name test/login-lockout and click Create. The Checkout branch checkbox switches you to the new branch right away.
Hint
Where to click:
⎇ main ▾ → New Branch… test/login-lockout → Create
The same in the terminal:
git switch -c test/login-lockout
You are on the test/login-lockout branch: its name is now in the top bar and in the status bar. For now the branch is just a new label on the same commit as main. Everything you commit next goes only into it.
Before a commit, always check the branch name in the top bar. Committing to the wrong branch is the most common beginner mistake.
Why create a separate branch for a task?
Now I’ll write the test case!
Step 3 · Changes
Yes! Open the file with the sign-in lockout test cases and add a new case. Git will notice right away that the file changed, but it won’t save the change to the history by itself.
How do I see what Git noticed?
Click “Insert test case TC-02” in the editor, then open the Commit window on the left (the second icon on the side bar). It lists all the changed files — the same thing the git status command shows.
Hint
Where to click:
Editor: “Insert test case TC-02” Side bar: Commit
The same in the terminal:
git status
The file is in the Changes list, and the IDE shows it in blue — in the project tree, on the tab and in the Commit window. The green bars next to the line numbers mark the new lines. But the file isn’t ticked yet: it is changed but not picked for a commit.
The file is in the Changes list but not ticked. Will it get into the commit?
How do I pick the file?
Step 4 · Picking files
Git has a staging area — the “basket” for the next commit. You decide what goes into it: in the terminal that’s the git add command, and in the IDE it’s the checkbox next to a file. If you changed five files but only two belong to the task, tick only those two.
Where is the checkbox?
Tick the login-lockout.md file in the Commit window.
Hint
Where to click:
Commit → Changes → ☑ login-lockout.md
The same in the terminal:
git add test-cases/login-lockout.md
The file is picked for the commit: in the diagram it moved to the second column. Everything ticked goes into the commit, and everything else stays in the working directory.
Now the commit?
Step 5 · The commit
Yes. A commit saves the ticked changes to the history as a snapshot: with the author, the time, a unique number (a hash) and a description. A good description says briefly what was done. Teams usually write it in English.
Where do I write the description?
Type the description Add TC-02 login lockout test case in the Commit Message field and click Commit.
Hint
Where to click:
Commit Message: Add TC-02 login lockout test case Commit
The same in the terminal:
git commit -m "Add TC-02 login lockout test case"
The commit is created: it appeared at the bottom in Git → Log with its own hash, and the file is no longer blue. But note: the commit exists only in your local repository. Nobody on GitHub can see it yet.
You made a commit. Can your teammates see it on GitHub?
How do I send it to GitHub?
Step 6 · Push
Push sends the commits from your branch to GitHub. GitHub doesn’t have the test/login-lockout branch yet, but the IDE will notice that and create it.
Where is that button?
Click the Push arrow (↗) in the IDE top bar. In the Push Commits window, check that the branch goes to origin : test/login-lockout marked New, and click Push.
Hint
Where to click:
Top bar: ↗ Push Push Commits → Push
The same in the terminal:
git push -u origin test/login-lockout
The branch and the commit are now on GitHub: look at the fourth column. GitHub noticed the new branch and offers to open a Pull Request right away. And the Console tab shows the command git push --set-upstream origin test/login-lockout: the IDE linked your branch to the branch on GitHub for you.
What is the difference between Commit and Push?
Opening a Pull Request!
Step 7 · Pull Request
A Pull Request is a request: “please look at my changes and merge my branch into main”. A PR shows all the commits and the changes line by line, teammates leave comments, and automatic checks (CI) run the tests.
What goes into a PR?
In the GitHub window, click Compare & pull request. Check that you are merging test/login-lockout into main, and give a clear title and description: what was done and why. Then click Create pull request.
Hint
Where to click:
GitHub: Compare & pull request Create pull request
The PR is open and the checks passed. But I left a comment and requested changes: TC-02 has no expected result. That’s a normal part of the job: review exists to catch things like this before the merge.
For a tester, a PR is an important source of information: the Files changed tab shows exactly what changed, which helps to plan the testing.
Why does the team use a Pull Request instead of merging branches right away?
How do I fix the comment?
Step 8 · Fixing after review
There’s no need to open a new PR. Just add a new commit to the same branch and push it: the PR follows the branch and updates by itself.
Repeat the same steps?
Yes, the same cycle. Click “Insert the expected result” in the editor, tick the file, type the description Add expected result to TC-02 and click Commit and Push… — that way the commit and the push happen in one go. In the Push Commits window, click Push.
Hint
Where to click:
Editor: “Insert the expected result” ☑ login-lockout.md Commit Message: Add expected result to TC-02 Commit and Push… → Push
The same in the terminal:
git add test-cases/login-lockout.md git commit -m "Add expected result to TC-02" git push
The new commit appeared in the PR, the checks passed again, and I approved the changes. Now the PR can be merged.
A reviewer asked you to fix the PR. What do you do?
Merging!
Step 9 · Merge
A merge brings the branch’s commits into main. We have an approval and green checks — everything the team’s rules require.
Where is that button?
On GitHub, click Merge pull request and then Confirm merge.
Hint
Where to click:
GitHub: Merge pull request → Confirm merge
The PR is merged: your test case is now in main on GitHub, and the whole team sees it. The test/login-lockout branch on GitHub can be deleted, the work in it is done.
The PR is merged on GitHub. Is the new test case in the main branch on your computer?
How do I update main?
Step 10 · Update Project
Go back to main and get the changes from GitHub. The IDE has Update Project for that (the blue ↙ arrow): it downloads new commits and adds them to the current branch, like git pull. People do this before starting every new task.
How do I do that?
Click the branch name in the top bar, choose main and click Checkout. Look at the editor. Then click Update Project (↙) and click OK in the window.
Hint
Where to click:
⎇ test/login-lockout ▾ → main → Checkout Top bar: ↙ Update Project → OK
The same in the terminal:
git switch main git pull
The local main caught up with GitHub: it has your commits and the merge commit. By the way, right after the switch the file had no new test case: your computer didn’t know about the merge on GitHub yet. Git doesn’t go online by itself, which is why you always click Update Project before starting work.
Thanks, Kadri!
You went through the whole path of a change in a team: Clone → New Branch → a tick → Commit → Push → Pull Request → review → Merge → Update Project. This cycle repeats in every task. In the terminal the same is done with the commands git clone, git switch -c, git add, git commit, git push and git pull.
Quick reference
Git and GitHub
Git is a version control system on your computer: it keeps the history of file changes. GitHub is the team’s shared base: the remote repository (origin) that holds the version of the project for everyone, where Pull Requests and reviews happen.
Commit and local repository
A commit is a snapshot of changes with a description, the author, the time and a hash. It lands in the local repository on your computer first: teammates can’t see it until you push.
Branches in the IDE
The current branch name is in the top bar. Click it: New Branch… creates a branch (with Checkout branch ticked it switches to it right away), and choosing a branch and Checkout switches to an existing one.
Commit in the IDE
The Commit window lists changed files (they are blue). A tick next to a file is the staging area (git add): only ticked files get into the commit. Write the description in the Commit Message field and click Commit or Commit and Push….
Push and Update Project
Push (↗) sends the branch’s commits to GitHub; the IDE creates a new branch there by itself. Update Project (↙) downloads new commits from GitHub into the current branch, like git pull. Git doesn’t go online by itself.
Pull Request and review
A PR is a request to merge a branch into main. It shows the commits and the changes line by line (Files changed), runs automated checks (CI), and teammates approve or request changes. Fixes are new commits to the same branch.
IDE and terminal
Get from VCS = git clone, New Branch = git switch -c, a tick = git add, Commit = git commit, Push = git push, Update Project = git pull. The Git → Console tab shows which commands the IDE ran.