|
| 1 | +course-info |
| 2 | +=========== |
| 3 | + |
| 4 | +GitHub Repo for http://dsg.csail.mit.edu/6.830/ |
| 5 | + |
| 6 | +We will be using git, a source code control tool, to distribute labs in 6.814/6.830. This will allow you to |
| 7 | +incrementally download the code for the labs, and for us to push any hot fixes that might be necessary. |
| 8 | + |
| 9 | +You will also be able to use git to commit and backup your progress on the labs as you go. Course git repositories will |
| 10 | +be hosted as a repository in GitHub. GitHub is a website that hosts runs git servers for thousands of open source |
| 11 | +projects. In our case, your code will be in a private repository that is visible only to you and course staff.` |
| 12 | + |
| 13 | +This document describes what you need to do to get started with git, and also download and upload 6.830/6.814 labs via |
| 14 | +GitHub. |
| 15 | + |
| 16 | +## Contents |
| 17 | + |
| 18 | +- [Learning Git](#learning-git) |
| 19 | +- [Setting up GitHub](#setting-up-github) |
| 20 | +- [Installing Git](#installing-git) |
| 21 | +- [Setting up Git](#setting-up-git) |
| 22 | +- [Getting Newly Released Labs](#getting-newly-released-lab) |
| 23 | +- [Word of Caution](#word-of-caution) |
| 24 | +- [Help!](#help) |
| 25 | + |
| 26 | +## Learning Git |
| 27 | + |
| 28 | +There are numerous guides on using Git that are available. They range from being interactive to just text-based. Find |
| 29 | +one that works and experiment; making mistakes and fixing them is a great way to learn. Here is a link to resources that |
| 30 | +GitHub suggests: |
| 31 | +[https://help.github.com/articles/what-are-other-good-resources-for-learning-git-and-github][resources]. |
| 32 | + |
| 33 | +If you have no experience with git, you may find the following web-based tutorial |
| 34 | +helpful: [Try Git](https://try.github.io/levels/1/challenges/1). |
| 35 | + |
| 36 | +## <a name="setting-up-github"></a> Setting Up GitHub |
| 37 | + |
| 38 | +Now that you have a basic understanding of Git, it's time to get started with GitHub. |
| 39 | + |
| 40 | +0. Install git. (See below for suggestions). |
| 41 | + |
| 42 | +1. If you don't already have an account, sign up for one here: [https://github.com/join][join]. |
| 43 | + |
| 44 | +### Installing git <a name="installing-git"></a> |
| 45 | + |
| 46 | +The instructions are tested on bash/linux environments. Installing git should be a simple `apt-get / yum / etc install`. |
| 47 | + |
| 48 | +Instructions for installing git on Linux, OSX, or Windows can be found at |
| 49 | +[GitBook: |
| 50 | +Installing](http://git-scm.com/book/en/Getting-Started-Installing-Git). |
| 51 | + |
| 52 | +If you are using Eclipse/IntelliJ, many versions come with git configured. The instructions will be slightly different than the |
| 53 | +command line instructions listed but will work for any OS. Detailed instructions can be found |
| 54 | +at [EGit User Guide](http://wiki.eclipse.org/EGit/User_Guide) |
| 55 | +, [EGit Tutorial](http://eclipsesource.com/blogs/tutorials/egit-tutorial), or |
| 56 | +[IntelliJ Help](https://www.jetbrains.com/help/idea/version-control-integration.html). |
| 57 | + |
| 58 | +## Setting Up Git <a name="setting-up-git"></a> |
| 59 | + |
| 60 | +You should have Git installed from the previous section. |
| 61 | + |
| 62 | +1. The first thing we have to do is to clone the current lab repository by issuing the following commands on the command |
| 63 | + line: |
| 64 | + |
| 65 | + ```bash |
| 66 | + $ git clone https://github.com/MIT-DB-Class/simple-db-hw-2021.git |
| 67 | + ``` |
| 68 | + |
| 69 | + Now, every time a new lab or patch is released, you can |
| 70 | + |
| 71 | + ```bash |
| 72 | + $ git pull |
| 73 | + ``` |
| 74 | + to get the latest. |
| 75 | + |
| 76 | + That's it. You can start working on the labs! That said, we strongly encourage you to use git for more than just |
| 77 | + downloading the labs. In the rest of the guide we will walk you through on how to use git for version-control |
| 78 | + during your own development. |
| 79 | + |
| 80 | +2. Notice that you are cloning from our repo, which means that it will be inappropriate for you to push your code to it. |
| 81 | + If you want to use git for version control, you will need to create your own repo to write your changes to. Do so |
| 82 | + by clicking 'New' on the left in github, and make sure to choose **Private** when creating, so others cannot see your |
| 83 | + code! Now we are going to change the repo we just checked out to point to your personal repository. |
| 84 | + |
| 85 | +3. By default the remote called `origin` is set to the location that you cloned the repository from. You should see the following: |
| 86 | + |
| 87 | + ```bash |
| 88 | + $ git remote -v |
| 89 | + origin https://github.com/MIT-DB-Class/simple-db-hw-2021.git (fetch) |
| 90 | + origin https://github.com/MIT-DB-Class/simple-db-hw-2021.git (push) |
| 91 | + ``` |
| 92 | + |
| 93 | + We don't want that remote to be the origin. Instead, we want to change it to point to your repository. To do that, issue the following command: |
| 94 | + |
| 95 | + ```bash |
| 96 | + $ git remote rename origin upstream |
| 97 | + ``` |
| 98 | + |
| 99 | + And now you should see the following: |
| 100 | + |
| 101 | + ```bash |
| 102 | + $ git remote -v |
| 103 | + upstream https://github.com/MIT-DB-Class/simple-db-hw-2021.git (fetch) |
| 104 | + upstream https://github.com/MIT-DB-Class/simple-db-hw-2021.git (push) |
| 105 | + ``` |
| 106 | + |
| 107 | +4. Lastly we need to give your repository a new `origin` since it is lacking one. Issue the following command, substituting your athena username: |
| 108 | + |
| 109 | + ```bash |
| 110 | + $ git remote add origin https://github.com/[your-repo] |
| 111 | + ``` |
| 112 | + |
| 113 | + If you have an error that looks like the following: |
| 114 | + |
| 115 | + ``` |
| 116 | + Could not rename config section 'remote.[old name]' to 'remote.[new name]' |
| 117 | + ``` |
| 118 | + |
| 119 | + Or this error: |
| 120 | + |
| 121 | + ``` |
| 122 | + fatal: remote origin already exists. |
| 123 | + ``` |
| 124 | + |
| 125 | + This appears to happen to some depending on the version of Git they are using. To fix it, just issue the following command: |
| 126 | + |
| 127 | + ```bash |
| 128 | + $ git remote set-url origin https://github.com/[your-repo] |
| 129 | + ``` |
| 130 | + |
| 131 | + This solution was found from [StackOverflow](http://stackoverflow.com/a/2432799) thanks to [Cassidy Williams](https://github.com/cassidoo). |
| 132 | + |
| 133 | + For reference, your final `git remote -v` should look like following when it's setup correctly: |
| 134 | + |
| 135 | + |
| 136 | + ```bash |
| 137 | + $ git remote -v |
| 138 | + upstream https://github.com/MIT-DB-Class/simple-db-hw-2021.git (fetch) |
| 139 | + upstream https://github.com/MIT-DB-Class/simple-db-hw-2021.git(push) |
| 140 | + origin https://github.com/[your-repo] (fetch) |
| 141 | + origin https://github.com/[your-repo] (push) |
| 142 | + ``` |
| 143 | + |
| 144 | +5. Let's test it out by doing a push of your master branch to GitHub by issuing the following: |
| 145 | + |
| 146 | + ```bash |
| 147 | + $ git push -u origin master |
| 148 | + ``` |
| 149 | + |
| 150 | + You should see something like the following: |
| 151 | + |
| 152 | + ``` |
| 153 | + Counting objects: 59, done. |
| 154 | + Delta compression using up to 4 threads. |
| 155 | + Compressing objects: 100% (53/53), done. |
| 156 | + Writing objects: 100% (59/59), 420.46 KiB | 0 bytes/s, done. |
| 157 | + Total 59 (delta 2), reused 59 (delta 2) |
| 158 | + remote: Resolving deltas: 100% (2/2), done. |
| 159 | + To [email protected]:MIT-DB-Class/homework-solns-2018-<athena username>.git |
| 160 | + * [new branch] master -> master |
| 161 | + Branch master set up to track remote branch master from origin. |
| 162 | + ``` |
| 163 | + |
| 164 | + |
| 165 | +6. That last command was a bit special and only needs to be run the first time to setup the remote tracking branches. |
| 166 | + Now we should be able to just run `git push` without the arguments. Try it and you should get the following: |
| 167 | + |
| 168 | + ```bash |
| 169 | + $ git push |
| 170 | + Everything up-to-date |
| 171 | + ``` |
| 172 | + |
| 173 | +If you don't know Git that well, this probably seemed very arcane. Just keep using Git and you'll understand more and |
| 174 | +more. You aren't required to use commands like commit and push as you develop your labs, but will find them useful for |
| 175 | +debugging. We'll provide explicit instructions on how to use these commands to actually upload your final lab solution. |
| 176 | + |
| 177 | +## Getting Newly Released Labs <a name="getting-newly-released-lab"></a> |
| 178 | + |
| 179 | +(You don't need to follow these instructions until Lab 1.) |
| 180 | + |
| 181 | +Pulling in labs that are released or previous lab solutions should be easy as long as you set up your repository based |
| 182 | +on the instructions in the last section. |
| 183 | + |
| 184 | +1. All new lab and previous lab solutions will be posted to the [labs](https://github.com/MIT-DB-Class/simple-db-hw) |
| 185 | + repository in the class organization. |
| 186 | + |
| 187 | + Check it periodically as well as Piazza's announcements for updates on when the new labs are released. |
| 188 | + |
| 189 | +2. Once a lab is released, pull in the changes from your simpledb directory: |
| 190 | + |
| 191 | + ```bash |
| 192 | + $ git pull upstream master |
| 193 | + ``` |
| 194 | + |
| 195 | + **OR** if you wish to be more explicit, you can `fetch` first and then `merge`: |
| 196 | + |
| 197 | + ```bash |
| 198 | + $ git fetch upstream |
| 199 | + $ git merge upstream/master |
| 200 | + ``` |
| 201 | + Now commit to your master branch: |
| 202 | + ```bash |
| 203 | + $ git push origin master |
| 204 | + ``` |
| 205 | + |
| 206 | +3. If you've followed the instructions in each lab, you should have no merge conflicts and everything should be peachy. |
| 207 | + |
| 208 | +## <a name="word-of-caution"></a> Word of Caution |
| 209 | + |
| 210 | +Git is a distributed version control system. This means everything operates offline until you run `git pull` |
| 211 | +or `git push`. This is a great feature. |
| 212 | + |
| 213 | +The bad thing is that you may forget to `git push` your changes. This is why we **strongly** suggest that you check |
| 214 | +GitHub to be sure that what you want us to see matches up with what you expect. |
| 215 | + |
| 216 | +## <a name="help"></a> Help! |
| 217 | + |
| 218 | +If at any point you need help with setting all this up, feel free to reach out to one of the TAs or the instructor. |
| 219 | +Their contact information can be found on the [course homepage](http://db.csail.mit.edu/6.830/). |
| 220 | + |
| 221 | +[join]: https://github.com/join |
| 222 | + |
| 223 | +[resources]: https://help.github.com/articles/what-are-other-good-resources-for-learning-git-and-github |
| 224 | + |
| 225 | +[ssh-key]: https://help.github.com/articles/generating-ssh-keys |
0 commit comments