Enterprise Java Development@TOPIC@
You will use Git in this class to perform an initial checkout and get updates for source files. Any Git client should be able to perform that function. You can determine if you have a command line Git client already installed using the following simple command.
Figure 3.1. Verifying if Git is Installed
//my Ubuntu system $ git --version git version 2.17.1
//my Mac system $ git --version git version 2.22.0
//my Windows system >git --version git version 2.22.0.windows.1
There are a number of options and some are going to be based on on your platform. Your basic options include command line or using an Eclipse plugin
Eclipse GUI Users: There is a git plugin for Eclipse available called EGit. It automatically comes with Eclipse these days, so no extra installation is required.
Linux Command-Line Users: Use your package installer. My normal choice is to select git, gitk, and git-gui packages.
//my Ubuntu system $ sudo apt update $ sudo apt install git gitk git-gui $ git --version git version 2.17.1
Mac Users: Although confusing at times, I find most development tools are available thru the brew package manager.
//my Mac $ brew update $ brew install git $ git --version git version 2.22.0
Cygwin Command-Line Users: Use the cygwin setup tool to locate the git packages
Windows Command-Line Users: Use one of the many available packagings for Git
git-scm example
Download and launch the installer
Pick your choice of editors.
Pick how deeply integrated with the Windows shell you want Git and Git bash commands to be. When working on Windows systems, I find the Git bash shell to be a very usable and lightweight alternative to Cygwin.
Choose your checkout style. Don't worry about commit style you will only be performing read-only checkouts. I chose "Checkout as-is, commit Unix-style line endings" since I used all linux-style editors on Windows. You may want the Window checkout format.
Choose your terminal window. I would recommend anything over the default Windows console window -- but that is a personal preference.
Click on the "Git Bash" icon after the installation is complete.
The class repository is located on github and can be browsed using the following http URL https://github.com/ejavaguy/ejava-student. With a cloned copy, you can receive file updates during the semester.
CD to a directory you wish to place source code. Make sure the path to this directory contains no spaces.
Clone the class repository using the following URL git://github.com/ejavaguy/ejava-student.git
$ git clone git://github.com/ejavaguy/ejava-student.git Cloning into 'ejava-student'... ... Checking out files: 100% (1289/1289), done. ... $ ls ejava-student/ ... $ cd ejava-student $ git branch -a //list all branches -- local and remote * master remotes/origin/HEAD -> origin/master remotes/origin/master
Git leaves you with all branches fetched and a local master branch referencing the class' master branch on github. You will be using the master branch for the duration of the semester. Other branches may show up, including my working branches where I am actively working on the next wave of updates. The master branch is usually updated the evening before or the day of class and should always be stable.
Perform a mock update. This is what you will be doing several times this semester to get file updates.
$ git checkout master #switches to master branch $ git pull #downloads changes and attempts merge Already up-to-date.
There are many modules within the class repository. Some are ready for use, some are still being worked, and some are not for use this semester. The ones ready for your use will be wired into the build and will be compiled during a follow-on section. The list will increase as the semester moves forward. Please ignore these extra modules. Keeping them within the baseline helps me keep related things centralized.
If you ever make changes to the class examples and would like to keep those changes separate from the updates. Store them in a new branch at any time using the following git commands.
$ git checkout -b new-branch #creates new branch from current branch #and switches to that branch $ git commit -am "saving my stuff" #commits all dirty files to new branch $ git checkout master #switches back to the master branch
If you simply want to throw away any changes you made, you can discard those changes to tracked files using the following git commands.
$ git reset --hard master $ git clean -rn #shows you what it would delete without deleting $ git clean -rf #deletes files not managed or specifically ignored by git