- Run
. setup.sh(or.\setup.ps1in 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 branchto see the two branches that are relevant for this exercise - What branch are you on?
- Use
git branch mybranchto create a new branch called mybranch - Use
git branchagain to see the new branch created. - Use
git checkout mybranchto switch to your new branch. - How does the output from
git statuschange 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.txtwith your name. Addthe file andcommitwith this change.- Use
git log --oneline --graphto see your branch pointing to the new commit. - Switch back to the branch called master.
- Use
git log --oneline --graphand notice how the commit you made on the mybranch branch is missing on the master branch. - Make a new file called
file2.txtand commit that file. - Use
git log --oneline --graph --allto 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 masterto see the difference between the two branches.
git checkoutgit checkout -bgit log --oneline --graphgit branchgit diff