Mysore University School of Engineering logo University of Mysore crest
Mysore University School of EngineeringDepartment of AI & ML · BAIL308C Project Management with Git
Class 3  ·  Saturday, 28 November 2026

Commit, branch, stash.

Last week Git arrived on your laptop. Today we use it: real commits, a branch, a merge, and a stash.
Abhishek Rai  ·  Experiments 1, 2 and 3
master
feature-branch
other-branch
Today  ·  two hours

Where we pick up today.

0:03
Recap
Save points, Git vs GitHub, three areas, init
0:10
Get ready
Open the project again, form laptop groups
0:22
First commit
add, commit, log, a second commit
Experiment 1
0:48
Branches
Create, switch, merge, then once alone
Experiment 2
1:36
Stash
Park unfinished work, bring it back
Experiment 3
1:52
Wrap-up
Recap and your practical record
A five-minute break before stash. We go slowly: every command, every laptop.
A question first
Last Saturday, what did git init do to your folder?
Take two or three answers, then press next.
01 Recap

What we did last week.

Commits are save points
Git is the engine, GitHub the garage
Installed Git, set name and email
Three areas: desk, bag, vault
git init made my-first-project a repository
Today
Put something in that repository, and save it for real.
Experiments 1, 2 and 3, start to finish.
01 Warm-up

Four questions from last week.

i.
Can you commit with the Wi-Fi off?
Yes. Git runs entirely on your laptop. Only GitHub needs the internet.
ii.
What does git config --global user.email set?
The email stamped on every commit you make on this laptop.
iii.
Name the three areas, in order.
Working directory, staging area, repository.
iv.
Which command tells you what is going on, any time you are unsure?
git status
02 Where we stopped

Open your project again.

Git Bash
cd Desktop/my-first-project
git status
On branch master
No commits yet
nothing to commit
this is exactly where we stopped
“No such file or directory”?
Type ls to see where you are, or start fresh: mkdir my-first-project, cd my-first-project, git init.
02 Everyone at a keyboard

One laptop, three people.

1
Form groups of three
Every group around one laptop with Git working.
2
Rotate the keyboard
Change typist each experiment, so all three type.
3
Everyone writes it down
The commands and output go in your own record.
New laptop today? Catch up here
# 1. install Git from git-scm.com, then:
git --version
# 2. tell Git who you are
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch master
# 3. make the project
cd Desktop
mkdir my-first-project
cd my-first-project
git init
Full install steps: Class 2's slides on the website.
03 The idea everything builds on

Three rooms every change walks through.

Room one
Working Directory
your messy desk
The files you see and edit.
Room two
Staging Area
the bag you pack
Changes chosen for the next commit.
Room three
Repository
the sealed vault
Permanent history in .git
git add
git commit
notes.txt untrackedstagedcommitted
03 Experiment 1 · type along

Make your first commit.

~/Desktop/my-first-project (master)
echo "Hello Git" > notes.txt
git status
Untracked files:
notes.txt
git add notes.txt
git status
Changes to be committed:
new file: notes.txt
git commit -m "Add initial notes file"
[master (root-commit) 89fdfae] Add initial notes file
1 file changed, 1 insertion(+)
Red
Git sees the file but is not tracking it yet.
Green
Staged. In the bag, ready to commit.
Committed
89fdfae is this save point's ID. Yours will be different.
03 Read the history

git log shows every save point.

my-first-project (master)
git log
commit 89fdfae488675e07c43438bc669489a75659defb
Author: Ada Lovelace <ada@example.com>
Date: Sat Nov 28 10:20:00 2026 +0530
Add initial notes file
git log --oneline
89fdfae Add initial notes file
committhe ID, a long hash
Authorfrom your git config
Datewhen you committed
Messagewhat changed
Long log and the prompt vanished? Press q to get back.
03 Your turn · five minutes

Make a second commit, on your own.

1
Create todo.txt with one line
echo "Buy milk" > todo.txt
2
Stage it
git add todo.txt
3
Commit with a real message
git commit -m "Add todo list"
4
Check: two commits?
git log --oneline
Commit messages
Weak"update"
Weak"final fix"
Clear"Add todo list"
Say what changed. Future you will thank you.
03 Everyone hits these

Three things that look scary, and are not.

1
A strange editor opened
You forgot -m. If it is Vim (full screen, no menus), quit with:
Esc:q!Enter
In Notepad: type a message on line 1, save, close.
2
A warning about LF and CRLF
warning: LF will be replaced by CRLF
Normal on Windows; it ends lines differently. Ignore it, your command worked.
3
“Please tell me who you are”
*** Please tell me who you are.
Git has no name or email yet. Run the two git config --global lines, then commit again.
Think about it
Five of you build one app, all editing master at the same time. What happens?
Take a guess, then press next.
04 Experiment 2

A branch is a safe copy to experiment in.

You want a new kitchen, so you build a full-size mock-up in the garage first. Only when it works do you bring it into the house.
masterthe real house, always working
feature-branchthe mock-up, try anything
try ideas here master stays safe
04 All you need

Four commands to branch.

CommandWhat it does
git branch feature-branchCreates a branch. You do not move onto it.
git checkout feature-branchMoves you onto that branch. git switch also works.
git branchLists branches. * marks the one you are on.
git merge feature-branchBrings that branch's commits into the branch you are on.
04 Experiment 2 · one step per press

Branch, commit, merge.

my-first-project
(press next for step 1)
git branch feature-branch
git branch
feature-branch
* master
git checkout feature-branch
Switched to branch 'feature-branch'
echo "Login page" > login.txt
git add login.txt
git commit -m "Add login page"
[feature-branch 61ad0c2] Add login page
git checkout master
Switched to branch 'master'
git merge feature-branch
Updating 1eb0565..61ad0c2
Fast-forward
your last commit
61ad0c2Add login page
master
feature-branch
HEAD
fast-forward
login.txt gone? It is safe on the branch.
Files in your folder
notes.txt
todo.txt
04 Your turn · eight minutes

Do the whole branch cycle, on your own.

1
Create a branch and move onto it
git branch about-page then git checkout about-page
2
Commit something on it
echo "About us" > about.txt, git add about.txt, git commit -m "Add about page"
3
Go back to master and merge
git checkout master then git merge about-page
4
Check your history
git log --oneline
What you should see at the end
git merge about-page
Updating 61ad0c2..0803954
Fast-forward
git log --oneline
0803954 Add about page
61ad0c2 Add login page
1eb0565 Add todo list
89fdfae Add initial notes file
four save points, in order
04 Not every merge is a fast-forward

Three ways a merge can go.

Fast-forward master slides here
Just slide forward
Master did not move. Git moves the label. No new commit.
Three-way merge
Both moved
Different parts changed. Git makes a new merge commit joining both.
Conflict ?
Same lines changed
Git will not guess. It pauses and asks you to choose.
04 When Git asks you to choose

A conflict is not a crisis.

<<<<<<< HEAD
Welcome to our app!
=======
Hello and welcome, friend!
>>>>>>> feature-branch
1
Open the file
Find the <<< === >>> markers.
2
Keep the right text
Delete the other version and all three marker lines.
3
Stage and commit
git add the file, then git commit.
Blue is where you are (HEAD). Pink is the branch coming in.
Break

Stretch. Water. Back in five.

Keep your terminal open in my-first-project. We use it next.
5:00
minutes left
Picture this
Half-way through editing, your teammate says: it is broken, fix it now.
You are not ready to commit. What do you do?
05 Experiment 3

Stash is a drawer for unfinished work.

switching with unfinished changes
git checkout other-branch
error: Your local changes to the following files
would be overwritten by checkout:
notes.txt
Please commit your changes or stash them
Git may refuse to switch with work in progress.
git stash puts it in a drawer, clears your desk, and lets you switch. Later you take it back out.
05 Experiment 3 · one step per press

Stash, switch, pop.

my-first-project (master)
(press next for step 1)
git branch other-branch
echo "Half-finished idea" >> notes.txt
git status --short
M notes.txt
git stash
Saved working directory and index state WIP on master
git stash list
stash@{0}: WIP on master: 0803954 Add about page
git checkout other-branch
...the urgent fix happens here...
git checkout master
git stash pop
modified: notes.txt
Dropped refs/stash@{0} (6838049...)
notes.txt
Hello GitHalf-finished idea
stash
stash@{0}
05 The stash family

Four stash commands.

CommandWhat it does
git stashPut unfinished changes in the drawer. Desk is clean.
git stash listSee everything in the drawer.
git stash popTake the newest one back out and remove it from the drawer.
git stash applyBring it back but keep a copy in the drawer.
06 Recap · I pick who answers

Six questions. Hands down.

i.
What does git init create?
A hidden .git folder. That is the repository.
ii.
Git vs GitHub, in one line?
Git tracks history on your laptop. GitHub hosts it online.
iii.
What is the staging area for?
Choosing exactly which changes go in the next commit.
iv.
Why branch instead of editing master?
Master stays working while you experiment safely.
v.
What does Fast-forward mean?
Master had not moved, so Git just slid its label forward.
vi.
What does stash solve?
Switching branches without committing unfinished work.
06 Before next class

Write up Experiments 1, 2 and 3.

Experiment 1
Setting up and basic commands
init, add, commit with a message.
Aim · Commands · Output · Result
Experiment 2
Create and merge a branch
branch, checkout, commit on the branch, merge into master.
Aim · Commands · Output · Result
Experiment 3
Stash
stash, switch branches, come back, stash pop.
Aim · Commands · Output · Result
Write the exact commands you typed and what the terminal printed. Each experiment is marked out of 10.
06 Next class

Your laptop meets your GitHub repo.

We download the repository you made in Class 1 onto your laptop, and keep the two in sync. Experiments 4, 5 and 6.
git clonegit fetchgit rebasemerge --no-ff
Bring
Laptop, charged
Git installed
Your GitHub login
BAIL308C  ·  Class 3

You made real commits.

Practise at home: flashcards, quiz, cheat sheet, and these slides.
git-github-by-abhirai2006.netlify.app
Questions? Ask now, or catch me after class.