Wiki
Clone wikicomputing / versioncontrol
Git Basics
This is only a cheat-sheet of the most common commands you will need on a daily basis. For more details and additional commands see ....
git clone <url>
Setup a repository for the first time by copying from the web
git add <folder or filename>
If you create new files or folders you must add them to git tracking
git commit -a -m "log message"
After adding or editing files, commit them so that git logs a bookmark at that point in time
git push
After commit, push to send your changes to the web repository
git pull
Each day start with a pull to retrieve the latest version from the web repository
git rm <folder or filename>
Deletes file from git repo
If you use rm
or any method other than git rm
to delete files from the local git repo, you have to instruct git to stage the changes of the untracked files using git add -u :/
.
Using Bitbucket
There are many methods for accessing the code. Where and how you use them differs slightly:
Cloning
You only have to do this step once to setup the a local copy of the repository.
What | When to use | How to use |
---|---|---|
ssh git clone | On your personal computer when you want Read/Write access, uses passphrase locked ssh key (same key as Farm) | git clone git@bitbucket.org:hijmans-lab/computing.git |
https git clone | On a server, uses password prompting for Read/Write access, asks for password on every push or pull. | git clone https://<username>@bitbucket.org/hijmans-lab/computing.git |
ssh read only git clone | On the server when you want Read-only access. Create a passphraseless ssh key, register it in the bitbucket project settings. Because it's read-only it can be shared with all users on the same systems. | git clone git@bitbucket.org:hijmans-lab/computing.git |
RStudio
RStudio has a git client built in. It's a little tricky to get started, as you are required to make the folder an RStudio project.
- The first time start by creating a new Project, and picking to check out from existing version control repository.
- It will then prompt you for the clone url, similar to the table above. You can get it from the overview page of the project you want to work with.
Examples:
Git Branches in RStudio
You have to do a little manual work to setup a Branch. The shell option on the More dropdown under the Git tab works great for this.
-
Create a Branch and Check it out. Git Checkout is a shortcut to create and switch to the new branch right away.
git checkout -b <nameofnewbranch>
-
Push the new branch to the online repo (Optional). If you want to share a branch across computers and let other people see it you need to push it to the server. RStudio won't be able to do this until to modify the Git config. While in your new branch run:
git push -u origin <nameofnewbranch>
-
That's it you should to be able to do all the normal stuff from RStudio now.
Forking and Sync
When working on external projects or large internal projects with multiple people Forking is often a good workflow to prevent conflicts.
Tracking the main project (upstream)
When using a Fork you often want to pull in changes from the main project. See these 2 links for how to track and pull changes into your Fork (aka sync) from the main code. * https://help.github.com/articles/configuring-a-remote-for-a-fork/ * https://help.github.com/articles/syncing-a-fork/
Options
There are several options for where to host projects under version control, issue tracking, and documentation.
Remote hosted
Local hosted
- Gitlab
- Redmine(or Chiliproject)
Pros and Cons
The options are very similar, they all offer issue tracking, wikis (in markdown, and available for offline editing), pull requests, and git based repositories. Colors of syntax highlighting, mobile stylesheet vary.
Bitbucket
Pros | Cons |
---|---|
Generous Academic License (Free Private Repos) | Only Academic Accounts get unlimited, and can expire |
Accounts findable by ucd email | Owned by Atlassian |
Wiki default .md extension works with RStudio | |
Supports Google, Github Login | |
Wiki edit preview |
Note: Google login can be done with UCD accounts (students), best to link after account creation.
Gitlab
Pros | Cons |
---|---|
Free Private Repos | Repo Limit 1 GB |
Nearly Identical to Github | Everyone needs another account |
Supports Google*, Github Login | Wiki default .markdown needs to be renamed to .md for RStudio |
Self Hosting option (see below) | No preview of online wiki edits |
Note: Google login can be done with UCD accounts (students), best at account creation time.
Github
Pros | Cons |
---|---|
Public repos more discoverable | Private Repos cost money |
Static website hosting | Everyone needs another account |
Self Hosted
Pros | Cons |
---|---|
Data Privacy | Admin Time (Patches and Backups) |
Campus Logins | Sustainability (Institutional Memory) |
No Limits | Not as social/discoverable |
ICE currently has a self hosted solution, code.ice It currently uses Chiliproject (a fork of Redmine). The biggest advantages are a more elaborate ticket system, and the ability to nest projects (searches can search sub-projects).
If we did self hosting of Gitlab at the College or Campus level that could make the service more sustainable.
Privacy
Some projects require more strict management of files. In most cases data should not be stored in version control, so this mostly applies to code and documentation.
Updated