-
Notifications
You must be signed in to change notification settings - Fork 0
Git Introduction
Contact: seantrott at icsi.berkeley.edu Contact: vivek at berkeley.edu
Much more information about Git can be found here, but here is a gentle guide to using Git for the purposes of ECG 2.0.
In general, we expect that the main actions you'll need to be familiar with are:
- cloning a repository
- pulling changes from a remote repository
- stashing changes
- committing changes and merging them with the new pull
The actions below apply to all of the repositories listed here
If you have Git installed, cloning is as simple as navigating (in Terminal/Git Bash) to the directory you want to install the repository in, and typing:
git clone <repository_url.git>
This creates a folder called repository_name
in that directory, which is initialized with a .git
folder containing information about the "upstream" or origin branch.
If updates are made to the core API, you might want to update your local version. This is also quite simple. Navigate to the repository directory, and enter:
git pull
If you've modified the repository in any way, this could raise a "conflict" error. See either "stashing" or "committing" for resolving this.
If you make changes to the repository, but they are minor and you don't care about saving them, then you can stash them. This will override your changes with the new remote updates. Enter:
git stash
If you do make valuable changes, you'll want to save them. You can enter something called a "commit". This means that Git will save the HEAD at the state at which your tracked files in the repository are currently at. If you've added new files, and want them to be tracked, enter:
git add FILENAME
To commit all the tracked files in the repository, enter:
git commit -am 'MESSAGE'
The contents of MESSAGE don't really matter, but it is helpful to have an informative description of what that commit accomplished, e.g.:
git commit -am 'Fixed bug in framework'
Finally, if there are conflicts on the same line, Git might not be able to resolve your new commit with the pulled changes. In that case, you'll have to manually select which version is preferred. This involves opening up the file and choosing either the remote or local versions of code.
Repository owners/administrators can directly push to the origin/master, but others cannot. If you do make a valuable change (fix a bug, add a feature, etc.), we ask that you either:
- Contact one of us (see above) to work out how to integrate the change
- Make a pull request, which we can review and incorporate
More information can be found here about making a pull request.