gitpractice.dev

brewly — Ch.4 · Bring back a deleted branch

Exercise 7 of 9

Before you start

Deleting a branch deletes a name

The commits stay in the repository. Find the last one in the reflog, then give it a name again.

git branch <name> <commit> creates a branch at any commit. Use the short id from the reflog, or a name such as HEAD@{1}.

There is no Undo button in this exercise.

git reflog
find the last commit you made on the branch
git branch <name> <commit>
create a branch at that commit
git log --oneline <name>
check what it contains
You can reopen this any time with “Lesson”.

Continue on a desktop

Typing git on a small screen is no fun. Open this page on a laptop or desktop to practise.

Back to the path