GitHub
Concepts
Overview
GitHub is a website that uses Git, a version-control system for tracking changes in source code during software development.
Conceptually, it is similar to cloud file storage like OneDrive or Google Drive, in that it can store folders and files, but it also has special features for programmers.
You can create a free account on GitHub.com
Key Terms
Repository = an on-disk data structure which stores metadata for a set of files and/or directory structure, one per project
Local repository on your computer
Remote repository on GitHub
Commit = "records changes to the repository", used in connection with your local repository
Push = sends to a remote repository
Pull = a Fetch followed by a Merge
Fetch = gets from a remote repository
Merge = combines repositories
Untracked = not staged or committed
Staged = about to be committed
Fork = copy a repository from one user’s account to another
Common Tasks on GitHub
Delete repository
Settings - scroll to bottom - Delete this repository button
Make repository private
Settings - scroll to bottom - Make private - button
Add collaborator
Settings - Collaborators (top left menu) - Search by username, full name or email address (my username is profvanselow)
Project Management
Add issues, add a project, Basic Kanban github.com/features/project-management/
Integration with IntelliJ IDEA, CLion, or PyCharm
One time per computer
Install Git
VCS -> Enable Version Control -> Git -> Download Git (one time, link in pop up or go to https://git-scm.com/downloads)
You could accept all of the defaults when installing Git but I recommend unchecking the box for Windows integration and changing the default editor to Notepad++
Configure Git
File -> Settings -> Version Control -> Git -> set Path to Git executable (if necessary)
Probably in C:\Program Files\Git\bin on home computer
Probably in C:\Users\username\AppData\Local\Programs\Git\bin on classroom computer
Sign in to GitHub
File -> Settings -> Version Control -> GitHub, +, log in to GitHub (uncheck box to set globally if on classroom computer)
One time per project
VCS -> Import into Version Control -> Share Project on GitHub
Every time you make a change to project
Commit (click green checkmark)
Type commit message (what you changed)
Click Commit button (or click the arrow next to Commit and choose Commit and Push)
if you only did Commit previously, Push from VCS -> Git menu or blue arrow
Files should be in repository on GitHub web site
One time on a different computer
From startup window or VCS menu...
Check out from Version Control -> Git. This will copy what is on GitHub to your computer.
Every time you start to work on one computer where you have already done the step above and after having pushed from a different computer
VCS -> Git -> Pull. This will update the local version with the version on GitHub.
If GitHub integration gets messed up
File -> Settings -> Version Control -> remove existing directory using the minus sign -
Go to that folder and delete the .git folder (it might be hidden)
On a Mac
PyCharm (or IntelliJ or CLion) menu -> Preferences -> Version Control -> Git -> locate Git
Preferences -> Version Control -> GitHub -> Add Account
Integration with Eclipse
One Time Per Project (on the computer that has the program)
1. Create a new project in Eclipse (or use an existing project)
2. Right click on the project, Team -> Share
3. Click Create button to create a local repository. C:\Users\username\OneDrive - Florida Gulf Coast University\git\repository\projectname
4. Right click project, Team -> Commit. This opens the Git Staging view.
5. Click the ++ icon to move files from Unstaged Changes to Staged Changes
6. Type a Commit Message, like "initial commit"
7. Click Commit and Push button
8. Create a repository on GitHub
9. Copy the repository URI (URL)
10. The copied URI should populate the URI box, if not, copy the address from GitHub and paste it in the box.
11. Add User and Password in Authentication. You can check the box to Store in Secure Store if you are on your own computer and don't want to have to put in the password every time.
12. Click Next, click Next, click Finish.
13. Go back to GitHub.com, refresh the repository page and see your project folders and files. (if all worked well)
If this doesn't work, create a new repository on GitHub and check the box to create a README, then click Upload files, and drag and drop your src folder into the browser page.
One Time Per Project (on a computer that doesn't have the program)
1. In Eclipse, File -> Import -> Git -> Projects from Git, click Next
2. Clone URI
3. Copy the URI from the main repository page on GitHub and paste it in the Location URI.
4. You do not need Authentication information if it was a public repository. Click Next, click Next.
5. Set the Directory to something like C:\Users\username\OneDrive - Florida Gulf Coast University\eclipse-workspace\projectname
6. Click Next, click Next, Finish
Every Time You Add to Code
1. Save All
2. Right click project, Team -> Commit
3. Click the ++ icon to move files from Unstaged Changes to Staged Changes
4. Type a descriptive Commit Message
5. Click Commit and Push button
Every Time You Sit at a Computer where you have already done the "One Time Per Project (on the computer that doesn't have the program)" but a more current version is on GitHub
1. Right click repository, Pull