Enterprise Java Development@TOPIC@

Chapter 3. Git Client Setup

3.1. Install Git Client
3.2. Get Class Repository

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

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.

  1. CD to a directory you wish to place source code. Make sure the path to this directory contains no spaces.

  2. 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
    

    Note

    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.

  3. 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.
    

    Note

    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.

    Note

    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