Git: Difference between revisions
| Line 35: | Line 35: | ||
git clone https://hwarpefelt@bitbucket.org/seslink/ses-test.git | git clone https://hwarpefelt@bitbucket.org/seslink/ses-test.git | ||
If they instead wanted the CP-norm repository, the command would be: | If they instead wanted the <tt>CP-norm</tt> repository, the command would be: | ||
git clone https://hwarpefelt@bitbucket.org/seslink/CP-norm.git | git clone https://hwarpefelt@bitbucket.org/seslink/CP-norm.git | ||
We'll start out by cloning the <tt>ses-test</tt> repository, which is a testing repository for the SESLINK git. This is a space where we are free to play around and nothing of worth is kept. You '''cannot''' break anything of importance in this repository, so feel free to experiment. We'll clone the repository using the <tt>git clone</tt> command, and should see output similar to this: | |||
$ git clone https://hwarpefelt@bitbucket.org/seslink/ses-test.git | $ git clone https://hwarpefelt@bitbucket.org/seslink/ses-test.git | ||
Revision as of 16:19, 21 December 2016
What is git?
Git is a version control system. In essence, it is a piece of software that handles changes to source code, and helps manage collaborative software development.
Git was initially developed by Linus Torvalds to be used as the version control system for the core components of the Linux family operating systems. It launched in 2005, and has since risen to become the most commonly used version control system in the world.
Files in git are stored in what is called repositories. These repositories, or repos for short, are file areas where changes to files are tracked.
In the SESLINK git there is also one level above these repositories, namely Projects. For the SESLINK git each model in the research projects is represented as a git project, and each git project has a number of repositories representing different versions of the model.
Installing git
Download git from the downloads section of the git website. Pick the version for your platform and install the file. Just click through the installer and go with any default options.
Accessing the repository
Bitbucket account
The SESLINK project uses Bitbucket as our git provider. Because of that, you will need a Bitbucket account to access the SESLINK repositories. Ideally our members should also apply for an academic license at bitbucket. This removes many of the restrictions on free accounts, and gives us more freedom to use the Bitbucket service. When applying for an academic license you will need to provide a bit of extra information, mostly in the form of the address of the department. Use the following:
Stockholm Resilience Center Kräftriket 2B ZIP: SE-10691 City & state/province: Stockholm
Once the application is submitted you should receive your academic license within a few days. You can, however, start working before you receive it.
Cloning repositories
Accessing the SESLINK repositories requires that you clone the repository to your local computer, which creates a folder with a local copy of the repository. Although there are graphical utilities available these seem to cause some issues, and because of that managing git is done preferably done using the command line (Command Prompt in Windows, Terminal in MacOS X). If you are previously unfamiliar with how to use the command line, here's a guide for Windows and one for MacOS X.
Once you've opened your command line utility, change directory to where you want to keep your repositories. From here, we'll use the git clone command to clone the repository. The basic syntax of this command is:
git clone https://USERNAME@bitbucket.org/seslink/REPOSITORY.git
In the example above, USERNAME is your username at bitbucket, and REPOSITORY is the repository that you want to clone. For example, if the user hwarpefelt wants to clone the ses-test repository they would issue the following command:
git clone https://hwarpefelt@bitbucket.org/seslink/ses-test.git
If they instead wanted the CP-norm repository, the command would be:
git clone https://hwarpefelt@bitbucket.org/seslink/CP-norm.git
We'll start out by cloning the ses-test repository, which is a testing repository for the SESLINK git. This is a space where we are free to play around and nothing of worth is kept. You cannot break anything of importance in this repository, so feel free to experiment. We'll clone the repository using the git clone command, and should see output similar to this:
$ git clone https://hwarpefelt@bitbucket.org/seslink/ses-test.git Cloning into 'ses-test'... remote: Counting objects: 58, done. remote: Compressing objects: 100% (50/50), done. remote: Total 58 (delta 17), reused 0 (delta 0) Unpacking objects: 100% (58/58), done. Checking connectivity... done.
If you are issuing the command for the first time you will be prompted to provide a username and password for bitbucket.
The exact number of objects in the example above aren't important at this stage, but if we list the contents of the directory we'll see that we now have a folder called ses-test in our folder. By changing into that we can now access the ses-test repository.