Skip to content

Latest commit

 

History

History
34 lines (30 loc) · 1.73 KB

README.md

File metadata and controls

34 lines (30 loc) · 1.73 KB

Git Kata: Basic Branching

Setup:

  1. Run source setup.sh (or .\setup.ps1 in PowerShell)

The task

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.

  1. Use git branch to see the two branches that are relevant for this exercise
  2. What branch are you on?
  3. Use git branch mybranch to create a new branch called mybranch
  4. Use git branch again to see the new branch created.
  5. Use git checkout mybranch to switch to your new branch.
  6. How does the output from git status change when you switch between the master and the new branch that you have created?
  7. How does the workspace change when you change between the two branches?
  8. Make sure you are on your mybranch branch before you continue.
  9. Create a file called file1.txt with your name.
  10. Add the file and commit with this change.
  11. Use git log --oneline --graph to see your branch pointing to the new commit.
  12. Switch back to the branch called master.
  13. Use git log --oneline --graph and notice how the commit you made on the mybranch branch is missing on the master branch.
  14. Make a new file called file2.txt and commit that file.
  15. 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.
  16. Switch to your branch mybranch.
  17. What happened to your working directory? Can you see your file2.txt?
  18. Use git diff mybranch master to see the difference between the two branches.

Useful commands

  • git checkout
  • git checkout -b
  • git log --oneline --graph
  • git branch
  • git diff