CHC4010 DevOps Week 7 Practical: Version Control
Part I. Simple Java Project
Create a new project
Powerin IntelliJ and create a new git repository in the project root folder.Complete a Java program in 4 steps:
Add new file Power.java to src folder
Add static method
power(x, y)that computes x to the power of yAdd
javadocforpower()methodTest
power()in main method
Make a commit for each step.
[!IMPORTANT] write meaningful commit messages. exclude unnecessary files and folders with .gitigore.
View your branch history with
git logandgit gui$- >$ Visualize All Branch History.
Part II. Remote Repository
Create a new repository on Gitee and connect it to your local repository in project Power.
Push your local
masterbranch to the remote repository.Refresh the page on Gitee and view the code in your remote repository.
Part III. Branching
Pull the latest version of
masterbranch from the remote repository to the local repository.Create a new branch called
testand switch to this branch.Write automated test for
power()method (refer to week 5 content) and commit it ontestbranch.View your branch history with
git logandgit gui$- >$ Visualize All Branch History.
Part III. Merging
Push
testbranch from the local repository to the remote repository.On Gitee, make a pull request for
testbranch and merge it to master. Resolve the conflicts in the Web UI if there are any.In your local repository, switch to
masterbranch and pull the latest version ofmasterbranch from the remote repository to the local repository.View your branch history with
git logandgit gui$- >$ Visualize All Branch History. How many commits are there on the master branch now?
Last updated