Set up Git
- Inlämningsdatum 13 sep 2017 av 17.01
- Poäng 1
- Lämnar in på papper
Step 1: Activate your KTH Github account
At KTH, we have an enterprise edition of Github running locally. As a student, you get a free account to use for university work, projects and so on. This is pretty much the same as regular www.github.com, expect private to KTH users. Several courses make use of version control (git) and project management tools (github), so it is good to have it setup from the beginning.
Goto https://gits-15.sys.kth.se/, and login to activate your account.
Step 2: Setup SSH Keys
SSH is a protocol that lets you connect and authenticate your computer with remote services, without needing to provide a username and password every time you access them.
n.b. this step can be problematic, so pay attention to the commands you are typing (measure twice, cut once!)
Generate a new SSH key pair Links to an external site.
Add the public key to your KTH Github account
Links to an external site.
To help out, watch this tutorial:
n.b. make sure you are in KTH Github - https://gits-15.sys.kth.se/ and not Public Github - www.github.com Links to an external site.
Step 3: Choose a Text Editor
When you interact with git, you will most likely use the command line (e.g. Bash) to issue commands. Some of these commands will launch a text editor so you can type messages (e.g. a description of a change you have made to a project). You can choose any text editor you like, but we recommend Atom (it's made by the github team after all).
Associate text editors with Git Links to an external site.
Step 4: Create a Repo
You can make as many repos on KTH Github as you like, and they can be public or private. The best way to think of a repo is a place for all the resources of a project to be stored and managed. As the project resources change over time, new versions will be created. All of the resources (and their previous versions) can be accessed through the repo. The first thing to do, is to make the repo:
Create a Repo Links to an external site.
Step 5: Basic flow
To complete this assignment, you must show that you can create a repo, and add new files to it, and create new versions which must be committed and pushed to the repo. It is important that you complete these steps using the command line interface.
- In the command line, cd into your intro folder
- Clone the repo from Step 4 to a local folder (e.g. $ git clone url/of/your/repo)
- n.b. check the web interface of your repo to find the url/of/your/repo
- List the contents of intro (e.g. $ ls) - you should see a clone of your repo as a folder - cd into it
- Using Atom, create a text file ($ atom my-file.md) and fill it with some plain text or Markdown Links to an external site. if you are feeling fancy
- Check the status of the local clone ($ git status) - read the message
- Add my-file.md to the repo ($ git add my-file.md)
- Check the status of the local clone ($ git status) - read the message
- Commit this change ($ git commit -a)
- You have to add a message describing the changes you made (hopefully in Atom, otherwise see Step 3 again)
- You have to close the Atom window to continue in the command line
- Push your changes to the remote repo on KTH Github (e.g. $ git push)
- n.b. sometimes you have to specify git push origin master
- Now, go back to the web interface for KTH Github and check your repo
- If it worked, you can see your added file, and read the commit message.
Feel free to read more at https://help.github.com/ Links to an external site. or watch other videos from a KTH perspective:
Cloning a Repo
Basic Git Workflow
To complete the assignment - show the repo and commit log to an assistant. You can find a receipt here for all assignments to print.