Create a topic branch and switch to the branch:
git switch -c dog-scaffold
Note that this command combines the two commands, git branch
and git switch
, that we used in the previous Git activity to create a new branch and switch to it.
Run the gloga
command.
Note that you now see HEAD -> dog-scaffold
, indicating that the new branch was created and that you are now on that branch; however, also note that you do NOT see origin/dog-scaffold
, because the GitHub repo does not yet know about the new branch.
Refresh the GitHub repo home page, and inspect the branches dropdown.
Note that the dog-scaffold
does NOT appear in the list.
Push the new branch up to the GitHub repo:
git push -u origin dog-scaffold
When you create a new local branch, you only need to run this longer form of the git push
command once. This command adds a remote branch of the same name and sets the remote branch to track with the local branch. Hereafter, you can use the short forms of git push
and git pull
.
Run the gloga
command.
Note that you now see origin/dog-scaffold
, indicating that the GitHub repo now has remote branch that is tracking with your local branch.
Refresh the GitHub repo home page, and inspect the branches dropdown.
Note that the dog-scaffold
now appears in the list.
Generate a scaffold for a dog resource:
rails generate scaffold Dog name breed date_of_birth:date
Reset and migrate the database:
rails db:migrate:reset
Run the server (rails server
) and test the scaffold in your browser (http://localhost:3000/dogs).
Once you are satisfied that the code is working correctly, stage all your changes and create a new commit:
git add -A
git commit
Add the log message, “Create dog-resource scaffold”, and save the commit: press Ctrl-X (to exit the editor), press Y (to confirm saving the log message), and press Enter (to confirm the location to save to).
Run the gloga
command.
Note that the local branch dog-scaffold
is now ahead of the remote branch origin/dog-scaffold
in the version history, because the new commit has not yet been pushed to the GitHub repo.
Refresh the GitHub repo home page, and inspect contents of the folder app/models/
.
Note that the dog.md
model class file is NOT present, because the latest commit has not yet been pushed.
Push the new commit up to the GitHub repo:
git push
Run the gloga
command.
Note that origin/dog-scaffold
has now caught up to the local branch dog-scaffold
in the version history, because the GitHub repo is now synced up with the local repo.
Refresh the GitHub repo home page, and inspect contents of the folder app/models/
.
Note that the dog.md
model class file is now present.