TUTORIAL_Git and GitHub - CSCI150GTeam/GTeamProject GitHub Wiki
Git and GitHub
Git is a distributed revision control system built to help keep track of source code revisions without the hassle of maintaining a connection to a server. GitHub is a website that hosts projects on their servers, provides a GUI to browse and edit project files, and a wiki to provide documentation. It also provides some social networking services. Git and GitHub aren't managed by the same people, rather GitHub was built to run on top of Git, providing the GUI and extra features while Git provided the core functions.
How it Works
-
Repositories:
A repository is a data structure that stores all the files in your project (header files, source code files, makefiles, resources, etc.), as well as other data associated with the files, such as a record of changes made to individual project files. -
Version Control Basics:
When a repository is first created, everybody works with the same set of files. When you sync your files, you receive changes made by your teammates, and they receive changes made by yours. However, sometimes it would be useful to have another copy of the code you can experiment on, without breaking the code for everybody else. Git allows you to create such a copy, called a branch. This new copy of the project will we developed separately from the main copy of the code, which is referred to as the trunk or master branch. A branch can be merged back into the master branch, or discontinued if it isn't needed anymore. -
Version Control Commands: (what you'll need to know to use Git properly)
- Creating a repository: You can either initialize an new repository, or clone an existing one. If you create a new repository, it will be stored on your hard drive, and only accessible to you until you put it online. If you clone an existing one, you'll receive a copy of the latest version of the repository, and be able to jump right in.
- Getting the latest changes: In order to get the latest version of the code, you use the pull command. In NetBeans, you go to
Team menu -> remote -> pullNote: you need to have the project open when accessing the Team menu, otherwise you may not see this option. Alternatively, you can right click on the project title (in the projects list on the left of the window) and selectgit -> remove -> pullThe pull operation gets the most recent version of the code and downloads it to your computer, then merges it with your local copy. - Submitting your changes: When you use the save command in NetBeans, you're only saving the files locally on your computer. To make changes to your repository, you must perform a commit. Before you select the commit command, you must select which files you want to add to your commit. To do this, right click on the project title, and select
git -> addThis will add all files in your project to the commit. Now that you've added the files you can perform the commit. Go toTeam menu -> commitThis should bring up a window. Write a description of your changes in the commit message. You can leave the author/commiter unchanged. Under 'files to commit' you'll see a list of files that will be included in your commit. By default, only files that have been edited will be added to this list (Note: Edited files are indicated with blue text). You can uncheck files you don't want to commit, then press the commit button when you're ready. Now, you've submitted your commit, but the commit has only been performed on the copy of the repository on your computer. To make the commit available for everybody, you have to push the changes. Go toTeam menu -> remove -> pushYou should now be able to see your commit on GitHub.