Using Git in Eclipse for CSSE230
In CSSE230, we will use a source control system called git. Here is how to checkout and manage a repo using Eclipse's Git plugin.
Note: if you are off campus, it is recommended (for better stability, and to avoid a potential blockage from the firewall) to connect to the Rose VPN before performing these commands.
Step 1: Cloning a Repository
- Open Eclipse and go to File > Import > Git > Projects from Git
- Select "Clone URI"
- Ignore the URI field for the moment, and fill out with the following:
- Host:
gitter.csse.rose-hulman.edu
- Repository path:
/srv/repos/csse230-202010-USERNAME
, replacing USERNAME
with your RHIT username
- Connection protocol: ssh
- User: your RHIT username
- Password: your RHIT password
- You can select Store in Secure Store to avoid having to enter credentials frequently.
The URI field should have been auto-filling as you filled the other fields, and should now read
ssh://USERNAME@gitter.csse.rose-hulman.edu/srv/repos/csse230-202010-USERNAME
with your username, of course. Hit Next.
- In branch selection make sure "master" is checked and click next.
- In local destination, you can configure anywhere you like (Eclipse may require you to use an empty directory.) Probably best to put it in a fresh directory devoted to CSSE230. Click next.
- Select "Import existing eclipse projects" and select next.
- You should see "WarmUpAndStretching" on the list, make sure it's checked and select Finish.
- You should see a folder for WarmUpAndStretching in your project browser.
Step 2: Test Push
Make a change to a file, save, and push it. Here's how:
- In the Package Explorer, open WarmUpAndStretching > src > anagram > Anagram.java. Make an edit: say, add a whitespace character, and save.
- In Package Explorer, you'll notice a > appear on any part of the project that has been changed since the last pull from master.
- Right click on one of these (say, the WarmUpAndStretching folder) and select Team > Commit.
- Verify that Anagram.java appears in your list of "Staged Changes".
- Add "test push" to the Commit Message.
- Select Commit and push.
- Note: if there are any files in the project that shouldn't ever be staged for commits (like a .gitignore file), you can right-click and choose "Ignore".
Step 3: Pull
Later, when working on a team project, you will want to pull changes that others have made. You can try it now, but no changes will be made since you have the up-to-date version.
- Right click on the project folder and select Team > Pull
- You should get the updated files.
Step 4: Let's do this!
You have the basics! Now its time to start working on the WarmUpAndStretching assignment.
Good Advice for Minimal Merge Conflicts
- This is for future reference, when working on a team.
- Pair program whenever possible
- Always do a Team Pull before you begin programming
- Always to a Team Commit/Push when you finish
- If you do have to resolve a merge conflict, remember you must accommodate both changes