Now that you've gotten a little theory, try practicing some of these techniques. To get some practice, do the following exercise step by step.
Try It Out For Yourself!
You've applied for a job on the tech team of a large media company. As part of the team's filtering process, they've sent you a series of skills tests to complete. Since the company uses GitHub in its day-to-day operations, the first of these tests will check your use of GitHub.
For the test, you have to follow a strict list of instructions, document the steps via screenshots, then send your work via a zip file to the HR team for review. The list of instructions are as followed:
Go to the GitHub website to access the practice project.
Fork the repository to your GitHub account.
Clone the repository with Git on your computer.
Use git log to look at the file structure and commits. Note how, many commits, trees, and blobs there are. Take a screenshot.
Create a new branch called "test," and checkout.
git logto look at your new branch.
Create a new file called
Write “GitHub is awesome!” in your file, and save it using a text editor.
Add and commit your new file to your branch. Take a screenshot.
git fetchto see if any new files are on the main repo. Take a screenshot.
git mergeto merge your branch to the master branch on your local repo.
Get on the master branch as your working directory.
Move the 2nd commit to a spot after the 4th commit.
Amend the commit message to “moved commit.”
Squash the 2nd, 3rd, and 4th commit into one.
Amend the commit message to “squashed 2,3,4.”
git reflogto look at your work. Take a screenshot.
Bonus (advanced): type in
gitk --all, screenshot the GUI graph of your repository, and commit it to your branch.
Bonus (advanced): use the command
git log --graph --full-history --all, take a screenshot, and commit it to your branch. Push your branch to the remote repository and create a pull request. Take a screenshot.
Check Your Work
Now, go through your screenshots and verify that all of the following is present:
The first screenshot shows the file structure and commits of the project underneath the git log command.
The second screenshot shows the new file "test" is committed on a new branch (NOT the master branch).
The third screenshot shows the git fetch command for the master branch on the remote repository.
The fourth screenshot shows:
The working directory is the master branch
Interactive rebase has been used to change the 2nd commit to a spot after the 4th commit
Interactive rebase has been used to squash the 2nd, 3rd and 4th commit into one
The commit message has been changed to “squashed 2,3,4”
The fifth screenshot shows a pull request from the branch to the remote repository.
All set? Now you're ready for the end of part quiz!