04 Prove
Version Control with GitHub
Objectives
-
Write Java code and configure it using git and GitHub
-
Practice Undoing Changes
Assignment
It this assignment, you will create a simple Java program and put it into GitHub. You will then ask one of your team members to make a change to your project. You will also make a change to another team member's project.
Create a project in IntelliJ called HelloFrom<Name> (if you first name was Bob, then this would be HelloFromBob).
Write code in your IntelliJ project to say "Hello, my name is <your name>". Run your program to make sure it works.
Share your project into Github by going to menu option VCS, selecting "Import into Version Control", and selecting "Share Project on Github". You may be prompted to login to Github. You will prompted to create a GitHub repository. Make sure that the repository is public (don't select the private checkbox). You will also be prompted to add the code (including other IntelliJ files associated with your project). After selecting Add, IntelliJ will automatically push your code into GitHub.
Goto GitHub and verify that you see your new repository.
While in Github, click on Settings and goto to Manage Access. Add all members of your team as collaborators for your project.
At least one member of your team must make a modification in your project. You must make at least one modification in another team members project. To make a modification in another project, goto IntelliJ and open the project from your team members GitHub repository by doing either one of the following:
Select menu option File, then New, then Project from Version Control; or
From the opening screen with no project open, select Get from Version Control
You will need to type in the URL for your teammate's repository in GitHub. You will also specify where you want the project to be placed on your hard drive.
Add a line of code in the program to display "Hello <your team members name>, my name is <your name>." Run the program to make sure it works.
Using either the Git tools in IntelliJ or using the Git Bash command line, commit and push your changes. If a merge conflict happens, you will need to manually fix the merge conflict.
In IntelliJ, open the Version Control window (goto View, Tool Windows, and select Git). Click on the Log tab in the Git Window. Observe the commits that you and others have made. Find the diff button to view the changes made to files in each commit.
After you have successfully updated someone else's project, take a screen shot of your repository in GitHub (instead of submitting code) and then take the quiz in I-Learn.
If you've made it this far successfully, you're eligible for a 93%. To be eligible for 100% credit, complete the Stretch Challenge below.
🌟Stretch Challenge (7%)🌟
-
See Changes Since Last Commit: Right click on a Java file (look in the git sub-menu and select compare with the same repository version) to view the changes made to it since the last commit or pull.
Undo Changes Since Last Commit: Right click on a Java file (look in the git sub-menu and select rollback to revert back the uncommitted changes. This does not use "git revert" but a form of "git checkout" which clears the local changes.
IntelliJ offers many options to undo changes by using git. Practice the following in one of your repositories (you will likely need to commit some changes to do these tests):
There are options to undo commits (includings ones you already pushed into GitHub). However, you are encouraged in this course to correct a bad commit with a new corrected commit. Look at the code to see what you need to change to fix a problem. Rely on the diff's provided between commits to see what you changed if you are uncertain.