- Run
source setup.sh
(or.\setup.ps1
in PowerShell)
You again live in your own branch, this time we will be doing a bit of juggling with branches, to show how lightweight branches are in git.
Hint: git checkout
will make you switch from one branch to another.
- Use
git branch
to see the two branches that are relevant for this exercise - What branch are you on?
- Use
git branch mybranch
to create a new branch called mybranch - Use
git branch
again to see the new branch created. - Use
git checkout mybranch
to switch to your new branch. - How does the output from
git status
change when you switch between the master and the new branch that you have created? - How does the workspace change when you change between the two branches?
- Make sure you are on your mybranch branch before you continue.
- Create a file called
file1.txt
with your name. Add
the file andcommit
with this change.- Use
git log --oneline --graph
to see your branch pointing to the new commit. - Switch back to the branch called master.
- Use
git log --oneline --graph
and notice how the commit you made on the mybranch branch is missing on the master branch. - Make a new file called
file2.txt
and commit that file. - Use
git log --oneline --graph --all
to see your branch pointing to the new commit, and that the two branches now have different commits on them. - Switch to your branch mybranch.
- What happened to your working directory? Can you see your
file2.txt
? - Use
git diff mybranch master
to see the difference between the two branches.
git checkout
git checkout -b
git log --oneline --graph
git branch
git diff