This is a simple game of tic-tac-toe with all parts implemented except for two methods. At this time, it does not:
- take a player's move and add it to the board
- correctly check for a tied game when there is no winner
Your job is to implement the first function (adding a player's move to the board), merge it with a branch that contains a solution for the second function, merge it to master, then push your changes.
Follow these instructions and answer the questions for yourself to understand what is going on.
- Fork the repository in your own GitHub account.
- Clone the repository to your local machine
- Run
git clone https://github.com/<your-username>/learn-git.git
- Run
cd learn-git
- Run
- Create your own branch where you implement and test
playerTurn(...)
- Run
git branch
. What do you see? What branch are you on? - Run
git log
. Notice which commits you see here. Pressq
to quit. - Run
git branch player-turn
, then rungit branch
. What do you see now? What branch are you on? - Run
git checkout player-turn
, then rungit branch
. What branch are you on now? - Run
git log
. Notice which commits you see here. Pressq
to quit. - Run
git checkout origin/check-tie
, then rungit log
. Notice which commits you see now. Pressq
to quit. - Run
git switch -c check-tie
, then rungit branch
. Notice what branch you are on now.
This switches to a new local branch which pushes to your remote branch. - Run
git checkout player-turn
. - Implement the method
playerTurn(...)
inEngine.java
.
- Run
- Stage and commit your changes.
- Run
git status
. What do you see? - Run
git add Engine.java
, then rungit status
again. What do you see now? - Run
git log
. Notice which commits you see. Pressq
to quit. - Run
git commit -m "<your-commit-message>"
- Run
git log
again. Notice which commits you see now. Pressq
to quit. - Run
git status
. What do you see now?
- Run
- Push your changes from this branch.
- Check your GitHub repository. Notice the commit history and branches.
- Run
git push -u origin player-turn
. Check your GitHub repository now, how have the branches and commit history changed?
The flag-u
sets your local branch to track a remote branch with the same name when you push for the first time. Usegit push
to make subsequent pushes in this branch. You can read more about this in the Git documentation, but don't worry about it for this tutorial.
- Merge your changes.
- Run
git merge check-tie
. How doesEngine.java
look? What did this command do? - Run
git log
. What did themerge
command do with all the previous commits? Did it make any new commits? - Run
git checkout master
, then rungit log
again. Notice which commits you see. Pressq
to quit. How doesEngine.java
look? - Run
git merge player-turn
. How doesEngine.java
look now? What did this command do? - Run
git log
. What did themerge
command do this time?
- Run
- Push your merged changes in master.
- Check your GitHub repository. Notice the commit history and branches.
- Run
git push
. Check your GitHub repository now, how have the branches and commit history changed?
We did not need to use the-u
flag this time because the local master branch was already set to push to the remote master branch.
- Git Exercises: https://github.com/eficode-academy/git-katas
- Complex Branching: https://learngitbranching.js.org/
- Git Game (this is less conceptual but makes you use some useful commands): https://github.com/git-game/git-game