├── CONTRIBUTING.md ├── LICENCE.md ├── README.md ├── crowdin.yml └── en ├── images ├── .keep ├── banner.png ├── clone.png ├── closed.png ├── download-git.png ├── fork.png ├── forking.png ├── gh-reg.png ├── gh-repo.png ├── git-icons.png ├── git-logo.png ├── github-shell.png ├── homebrew.png ├── installed-git.png ├── instructions.png ├── issue.png ├── issues.png ├── login-github.png ├── new-repo.png ├── new-repo2.png ├── pull.png ├── pull2.png ├── pull3.png ├── pull4.png ├── spotlight.png └── terminal.png ├── meta.yml ├── resources ├── .keep └── example.py ├── solutions └── .keep ├── step_1.md ├── step_10.md ├── step_11.md ├── step_12.md ├── step_13.md ├── step_14.md ├── step_2.md ├── step_3.md ├── step_4.md ├── step_5.md ├── step_6.md ├── step_7.md ├── step_8.md └── step_9.md /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | All contributions are assumed to be licensed under the same licence as the source, i.e. [CC BY-SA](http://creativecommons.org/licenses/by-sa/4.0/). This licence must remain in all derivatives of this work. 4 | 5 | ## Issues 6 | 7 | If you find a mistake, bug or other problem, please [open an issue](https://github.com/raspberrypilearning/getting-started-with-git/issues) in this repository. 8 | 9 | ## Pull Requests 10 | 11 | If you fix a mistake, bug or problem or have something to contribute, please create a pull request for each modification. Please consider grouping modifications sensibly, i.e. don't bundle typo fixes in the same pull request as code changes, instead file them separately. 12 | 13 | Please note that sometimes things are done for pedagogical reasons so changes which make sense from a software engineering perspective (reducing duplication or making use of more advanced programming language features) may not be suitable to maintain the intended educational value. 14 | 15 | ## Derivatives 16 | 17 | The licence must remain in all derivatives of this work. 18 | 19 | ## Licence 20 | 21 | Unless otherwise specified, everything in this repository is covered by the following licence: 22 | 23 | [![Creative Commons Licence](http://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/) 24 | 25 | ***Getting Started with Git*** by the [Raspberry Pi Foundation](http://www.raspberrypi.org) is licenced under a [Creative Commons Attribution 4.0 International Licence](http://creativecommons.org/licenses/by-sa/4.0/). 26 | 27 | Based on a work at https://github.com/raspberrypilearning/getting-started-with-git 28 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | # Licence 2 | 3 | Unless otherwise specified, everything in this repository is covered by the following licence: 4 | 5 | [![Creative Commons License](http://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/) 6 | 7 | ***Getting Started with Git*** by the [Raspberry Pi Foundation](http://www.raspberrypi.org) is licenced under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/). 8 | 9 | Based on a work at https://github.com/raspberrypilearning/getting-started-with-git 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting started with Git 2 | 3 | ![](en/images/banner.png) 4 | 5 | Learn how to use Git and GitHub from the command line on Linux, Mac OS, and Windows 6 | 7 | ## Licence 8 | 9 | Unless otherwise specified, everything in this repository is covered by the following licence: 10 | 11 | [![Creative Commons License](http://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/) 12 | 13 | ***Getting Started with Git*** by the [Raspberry Pi Foundation](http://www.raspberrypi.org) is licenced under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/). 14 | 15 | Based on a work at https://github.com/raspberrypilearning/getting-started-with-git 16 | -------------------------------------------------------------------------------- /crowdin.yml: -------------------------------------------------------------------------------- 1 | files: 2 | - source: /en/**/*.* 3 | translation: /%locale%/**/%original_file_name% 4 | -------------------------------------------------------------------------------- /en/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/.keep -------------------------------------------------------------------------------- /en/images/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/banner.png -------------------------------------------------------------------------------- /en/images/clone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/clone.png -------------------------------------------------------------------------------- /en/images/closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/closed.png -------------------------------------------------------------------------------- /en/images/download-git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/download-git.png -------------------------------------------------------------------------------- /en/images/fork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/fork.png -------------------------------------------------------------------------------- /en/images/forking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/forking.png -------------------------------------------------------------------------------- /en/images/gh-reg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/gh-reg.png -------------------------------------------------------------------------------- /en/images/gh-repo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/gh-repo.png -------------------------------------------------------------------------------- /en/images/git-icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/git-icons.png -------------------------------------------------------------------------------- /en/images/git-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/git-logo.png -------------------------------------------------------------------------------- /en/images/github-shell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/github-shell.png -------------------------------------------------------------------------------- /en/images/homebrew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/homebrew.png -------------------------------------------------------------------------------- /en/images/installed-git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/installed-git.png -------------------------------------------------------------------------------- /en/images/instructions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/instructions.png -------------------------------------------------------------------------------- /en/images/issue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/issue.png -------------------------------------------------------------------------------- /en/images/issues.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/issues.png -------------------------------------------------------------------------------- /en/images/login-github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/login-github.png -------------------------------------------------------------------------------- /en/images/new-repo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/new-repo.png -------------------------------------------------------------------------------- /en/images/new-repo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/new-repo2.png -------------------------------------------------------------------------------- /en/images/pull.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/pull.png -------------------------------------------------------------------------------- /en/images/pull2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/pull2.png -------------------------------------------------------------------------------- /en/images/pull3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/pull3.png -------------------------------------------------------------------------------- /en/images/pull4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/pull4.png -------------------------------------------------------------------------------- /en/images/spotlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/spotlight.png -------------------------------------------------------------------------------- /en/images/terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/images/terminal.png -------------------------------------------------------------------------------- /en/meta.yml: -------------------------------------------------------------------------------- 1 | --- 2 | title: Getting started with Git 3 | hero_image: images/banner.png 4 | description: Learn how to use Git and GitHub from the command line on Linux, Mac OS 5 | and Windows 6 | original_url: https://raspberrypi.org/learning/getting-started-with-git 7 | theme: yellow 8 | duration: 2 9 | listed: false 10 | ingredient: false 11 | copyedit: true 12 | curriculum: 2, design-0, programming-0, phys-comp-0, manufacture-0, community-2 13 | interests: '' 14 | technologies: '' 15 | site_areas: projects 16 | hardware: '' 17 | software: '' 18 | version: 3 19 | last_tested: 2017-01-01 20 | steps: 21 | - title: Introduction 22 | - title: What you will need 23 | - title: What is Git? 24 | - title: Getting Git 25 | completion: 26 | - engaged 27 | - title: Setting up Git 28 | - title: Creating your first magic school bag 29 | - title: Adding your books 30 | - title: Adding more books and travelling in time 31 | - title: Making major changes 32 | - title: Working with a sky-bag 33 | - title: Collaborative working 34 | - title: GitHub issues 35 | - title: Pull requests 36 | completion: 37 | - internal 38 | - title: What next? 39 | -------------------------------------------------------------------------------- /en/resources/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/resources/.keep -------------------------------------------------------------------------------- /en/resources/example.py: -------------------------------------------------------------------------------- 1 | print("Hello world") 2 | -------------------------------------------------------------------------------- /en/solutions/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypilearning/getting-started-with-git/d8ae05dfbd59d681cafbbabdb510b7223574cab5/en/solutions/.keep -------------------------------------------------------------------------------- /en/step_1.md: -------------------------------------------------------------------------------- 1 | ## What you will make 2 | In this resource, you will learn how to use the Git version control software to help you to work on your own projects and contribute to open-source projects. 3 | 4 | ## What you will learn 5 | In this resource you will learn: 6 | 7 | - How to manage your projects using Git 8 | - How to use GitHub to store remote versions of your projects 9 | - How to collaborate on open-source software and projects using GitHub 10 | 11 | This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): 12 | 13 | - [Collaborate on digital making projects with other community members](https://www.raspberrypi.org/curriculum/community-and-sharing/builder) 14 | 15 | 16 | -------------------------------------------------------------------------------- /en/step_10.md: -------------------------------------------------------------------------------- 1 | ## Working with a sky-bag 2 | 3 | Now that you know how to do the basics in Git, it's time to learn how to use it to its full potential: use it to share your work and collaborate with others. 4 | 5 | There are lots of services that will host your Git repo for you, free of charge. [GitLab](https://about.gitlab.com/) is one such service and [BitBucket](https://bitbucket.org/) is another. In this resource, you are going to be using [GitHub](https://github.com/), which is one of the more popular services. 6 | 7 | - The first thing to do is to register for an account on [GitHub](https://github.com/join?source=header-home), and just choose the free plan. 8 | 9 | ![](images/gh-reg.png) 10 | 11 | - Now that you have an account, you can create a `snitch-sniffer` repo on GitHub. Find the **New repository** button and click it. 12 | 13 | ![](images/new-repo.png) 14 | 15 | - Give the repo a name and a description and click on the **Create repository** button 16 | 17 | ![](images/new-repo2.png) 18 | 19 | - This should then bring up a page of instructions 20 | 21 | ![](images/instructions.png) 22 | 23 | - As you already have a repo ready to push to GitHub, then all you need to do is make sure you are in your project directory and type: 24 | 25 | ```bash 26 | git remote add origin git@github.com:HarryPotter/snitch-sniffer.git 27 | ``` 28 | 29 | and then 30 | 31 | ```bash 32 | git push -u origin master 33 | ``` 34 | 35 | - If you look on GitHub, you should now be able to see your repo, along with the displayed `README.md` file that you wrote. 36 | 37 | ![](images/gh-repo.png) 38 | 39 | - Any time you make changes to your project, and you want to push them up to GitHub, you can just type: 40 | 41 | ```bash 42 | git push origin master 43 | ``` 44 | 45 | If you are working on a different branch you would type: 46 | 47 | ```bash 48 | git push origin 49 | ``` 50 | 51 | -------------------------------------------------------------------------------- /en/step_11.md: -------------------------------------------------------------------------------- 1 | ## Collaborative working 2 | 3 | The true power of services like GitHub becomes apparent when you start working with other people. GitHub lets other people make their own copies of your projects, or you to make copies of theirs. Either of you can then make improvements to the project and then push the improvements up to GitHub for everyone to share. 4 | 5 | This resource is itself a GitHub repo. You can find it at [https://github.com/raspberrypilearning/getting-started-with-git](https://github.com/raspberrypilearning/getting-started-with-git). That means that if you found a mistake in the resource, or if you just wanted to make some improvements, you can. There are two main ways to get involved with other people's projects: **issues** and **pull requests**. 6 | 7 | -------------------------------------------------------------------------------- /en/step_12.md: -------------------------------------------------------------------------------- 1 | ## GitHub issues 2 | 3 | Our copy editors at Raspberry Pi are pretty amazing, so the chances of you spotting a typo in this resource are pretty slim. You might spot a mistake in some of the code though, and that's where you can help out. Take this bit of code for example: 4 | 5 | ```python 6 | print("Hello World!) 7 | ``` 8 | 9 | Let's see how you could help fix this error. 10 | 11 | - Head on over to [https://github.com/raspberrypilearning/getting-started-with-git](https://github.com/raspberrypilearning/getting-started-with-git), and make sure you are logged in. 12 | 13 | - Now, you want to find the **Issues** tab 14 | 15 | ![](images/issues.png) 16 | 17 | - You can now create a new issue, and give a description 18 | 19 | ![](images/issue.png) 20 | 21 | - Once that's completed, the maintainers of the repo will be able to reply to you, and close the issue once it's fixed. 22 | 23 | ![](images/closed.png) 24 | 25 | -------------------------------------------------------------------------------- /en/step_13.md: -------------------------------------------------------------------------------- 1 | ## Pull requests 2 | 3 | Issues are great, but if you want to help out even more, then project maintainers are usually very happy for you to fix or improve projects yourself. To do this, you need to make your own copy of the repo so that you can work on it. 4 | 5 | - On the projects main page, find the **Fork** button, and click it. 6 | 7 | ![](images/fork.png) 8 | 9 | - You will now have a copy of the repo. You should see a **Clone or download** button. Clicking this will reveal the uniform resource identifier (URI) of the repo. Now, using the terminal, you can clone the repo to your computer with `git clone`: 10 | 11 | ```bash 12 | git clone https://github.com/HelpfulUser/getting-started-with-git.git 13 | ``` 14 | 15 | - All the files and directories will now be on your computer. Go ahead and make the changes you want, then commit them and push them back up to GitHub, just like you would normally do. Here your commit message is particularly important, as it will explain the changes you have made to the resource's original owner. 16 | 17 | - You can now head back over to GitHub. Find the button that says **New pull request**. 18 | 19 | ![](images/pull.png) 20 | 21 | - Click the button and then click on the **Create pull request** button. 22 | 23 | ![](images/pull2.png) 24 | 25 | - Your commit message will be there, but you can change it and even add a more detailed description if you like. 26 | 27 | ![](images/pull3.png) 28 | 29 | - Once you're happy, click the **Create pull request** button. The maintainer of the repo will then be able to see your pull request. They can then choose to merge it into their repo, or close it. 30 | 31 | ![](images/pull4.png) 32 | 33 | -------------------------------------------------------------------------------- /en/step_14.md: -------------------------------------------------------------------------------- 1 | ## What next? 2 | 3 | - Now that you have an understanding of the way Git and GitHub works, you could start using it for all your projects. 4 | 5 | - When you create a project, don't forget to tell people about it, and send them links to your GitHub repos. That way they can use your code and maybe even help to make it better. 6 | 7 | - Why not find a project that you could help out with on GitHub? You can help with anything from improving the code and the documentation to fixing little typos. 8 | 9 | -------------------------------------------------------------------------------- /en/step_2.md: -------------------------------------------------------------------------------- 1 | ## What you will need 2 | 3 | - An internet connected computer 4 | -------------------------------------------------------------------------------- /en/step_3.md: -------------------------------------------------------------------------------- 1 | ## What is Git? 2 | 3 | ![logo](images/git-logo.png) 4 | 5 | Git is a version control system (VCS) for tracking changes to files and coordinating changes between multiple people who are all working on the same code base. 6 | 7 | One way to think about Git is to imagine a magical school bag. You can pull books out of your bag and do some work whenever you like. Once you've finished your homework, you can put the books back into your school bag, and the bag remembers what changes you made to all the books inside it. 8 | 9 | What's really clever is that this school bag can be synchronised with another magical school bag that lives in the clouds. Whenever you like, you can tell the bag to copy the contents of all the books to the sky-bag. If you lose your own school bag, you don't have to worry, as you can just get a new one and grab all the books and writing from the sky-bag. 10 | 11 | That's not all though. All your friends at school also have magical school bags. They also keep their bags synchronised with the sky-bag. This means that you and your friends can all work on the homework together. If a friend has a better answer to a science question than you do, you can copy their answer from the sky-bag to your book. 12 | 13 | It gets even better than that: your teacher also has a magical school bag. When she wants to check the homework, she just copies all the books from the sky-bag to her bag. She can then check through the answers from the whole class in one go. If she spots a mistake, she can write a comment in the margin of the book, and then all the magical bags from the whole class will receive the comment. Only one person in the class needs to correct the mistake though, and then everyone in the class immediately has the correct answer. 14 | 15 | -------------------------------------------------------------------------------- /en/step_4.md: -------------------------------------------------------------------------------- 1 | ## Getting Git 2 | 3 | If you're working on a Raspberry Pi, then congratulations: Git already is installed in Raspbian by default. If you're using Mac OS, then you can follow the collapsed section below to instal Git and then return here to learn how to use it. 4 | 5 | --- collapse --- 6 | --- 7 | title: Installing Git on Mac OS 8 | --- 9 | 10 | Getting Git set up on Mac OS is easy, and has the added benefit of giving you a package manager to install lots of other awesome and open-source software. 11 | 12 | 1. You're going to need to start by typing a command into a terminal window on Mac OS. This will install the [Homebrew package manager](https://brew.sh/), which is pretty similar to **apt** on Linux. 13 | 14 | ![homebrew](images/homebrew.png) 15 | 16 | 1. Open up a terminal window by typing `Cmd + Space` to open Spotlight and then type `terminal` into the search field. 17 | 18 | ![spotlight](images/spotlight.png) 19 | 20 | 1. Now copy and past the following command into the terminal window to install Homebrew. 21 | 22 | ```bash 23 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 24 | ``` 25 | 26 | ![terminal](images/terminal.png) 27 | 28 | 1. You can hit **Return** at the prompts and allow Homebrew to install. Once it is finished, you'll have Git installed on Mac OS, as it's an integral part of Homebrew. You can return to the [main worksheet](worksheet.md), and carry on following the guide. 29 | 30 | ![installed](images/installed-git.png) 31 | 32 | 1. As an added bonus, you now have an amazing package manager which you can use to install software. For instance, you can install Emacs just by typing `brew install emacs` into a terminal window. 33 | --- /collapse --- 34 | 35 | If you're on Windows, then you can follow the collapsed section below to install the Git shell. 36 | 37 | --- collapse --- 38 | --- 39 | title: Installing Git on Windows 40 | --- 41 | The easiest way to install Git on Windows is to use GitHub's application. If you do not already have a GitHub account, you should begin by setting one up, as this will make things easier later on. 42 | 43 | 1. Register for an account on [GitHub](https://github.com/join?source=header-home), and choose the free plan. 44 | 45 | ![](images/gh-reg.png) 46 | 47 | 1. Head over to [desktop.github.com](https://desktop.github.com/) and click on the **Download** button to download the GitHub app. 48 | 49 | ![github](images/download-git.png) 50 | 51 | 1. Once the file has downloaded, double click on the `.exe` file and follow the onscreen instructions to install. Near the end of the registration, you'll need to use your GitHub credentials to log in, and then proceed through the rest of the steps. 52 | 53 | ![authenticate](images/login-github.png) 54 | 55 | 1. Once the setup has completed, you should see two new icons on your desktop and in your Application menu. 56 | 57 | ![icons](images/git-icons.png) 58 | 59 | 1. You can use the graphical version of the GitHub app, but if you want to follow the rest of the [worksheet](worksheet.md), you should use the **Git shell** app, which is a command line interface (CLI), to use Git. This way, you'll feel comfortable working on other operating systems, and you will also learn a little Bash (Bourne-again shell). 60 | 61 | ![github-shell](images/github-shell.png) 62 | 63 | 1. As the GitHub app has configured your username and email address, you can skip the **Setting up Git** section of the main worksheet. 64 | 65 | --- /collapse --- 66 | 67 | Lastly, if you're on Linux, and you don't have Git installed, then you can just use your package manager to grab the software. Something like this should work: 68 | 69 | ```bash 70 | sudo apt install git 71 | ``` 72 | 73 | -------------------------------------------------------------------------------- /en/step_5.md: -------------------------------------------------------------------------------- 1 | ## Setting up Git 2 | 3 | You're going to be working in a terminal window for the duration of this resource, so open it up by clicking on the icon on the desktop, or by pressing `Ctrl + Alt + T` on your keyboard. 4 | 5 | - The first thing to do is to tell Git who you are. This is important, as Git can be used collaboratively by lots of people, so it needs to know who made changes to which files. You can use your own username and email address, unless you are in fact the Boy Who Lived. 6 | 7 | ```bash 8 | git config --global user.name "Harry Potter" 9 | git config --global user.email "h.potter@hogwarts.prof" 10 | ``` 11 | 12 | - Next you need to tell Git which text editor you want to use. If you don't have any particularly strong feelings about text editors, then you can just type: 13 | 14 | ```bash 15 | git config --global core.editor nano 16 | ``` 17 | 18 | -------------------------------------------------------------------------------- /en/step_6.md: -------------------------------------------------------------------------------- 1 | ## Creating your first magic school bag 2 | 3 | So you want to start a new project? Maybe it's a special ultrasonic range finder for tracking flying objects in the air. You'll want a directory on your computer for all your files to sit in, so the first thing to do is create that directory. 4 | 5 | - In the terminal, you can use the `mkdir` (make directory) command to create a new directory. 6 | 7 | ```bash 8 | mkdir snitch-sniffer 9 | ``` 10 | 11 | - Now you want to go into that directory. You can use the `cd` (change directory) command to do this. 12 | 13 | ```bash 14 | cd snitch-sniffer 15 | ``` 16 | 17 | - Next, you can create a file that will tell people what the project is about. You can use any text editor to do this, such as Notepad, TextEdit or Gedit. Create a file called `README.md`. The `.md` extension stands for **Markdown**, which is a markup language. You can learn more about Markdown [here](https://daringfireball.net/projects/markdown/). 18 | 19 | - You can now give the file a title and write a short explanation of what your project is about. 20 | 21 | ```markdown 22 | # The Golden Snitch Sniffer 23 | This is a project that uses multiple long-range ultrasonic sensors to find and track 24 | an object flying in three-dimensional space. It displays the object's coordinates, 25 | speed, and trajectory through a VR headset. 26 | ``` 27 | 28 | - Pressing `Ctrl + X` will cause a save prompt to appear. You can type `Y` to save and then hit `Enter` to close nano. 29 | 30 | - Your file should have been created and will now be sitting in your directory. You can type `ls` in the terminal or `dir` if you are using Windows, to see a list of files. 31 | 32 | ```bash 33 | ls 34 | ``` 35 | 36 | - At the moment, the directory is just like any other directory on your system. You now need to make the magical school bag part. This is known as a **Git repository**, and it takes the form of a hidden directory that keeps track of all the changes to the working directory. Type the following to create the repository, which from now on will just be called a **repo**: 37 | 38 | ```bash 39 | git init 40 | ``` 41 | 42 | - If you type `ls` again, nothing will appear to have changed. You can use `ls -a` to see all the hidden files and directories, though. If you are using Windows then type `dir /A` instead. 43 | 44 | ``` 45 | ls -a 46 | ``` 47 | 48 | - You should now see something like this in your terminal window: 49 | 50 | ```bash 51 | . .. .git README.md 52 | ``` 53 | 54 | - That `.git` directory is the **repo skeleton**. You can have a look inside it by typing the following. (Remember if you are using Windows it would be `dir /A .git`.) 55 | 56 | ```bash 57 | ls -a .git 58 | ``` 59 | 60 | - This should bring up something like: 61 | 62 | ```bash 63 | branches config description HEAD hooks info objects refs 64 | ``` 65 | 66 | - You don't really need to worry about this directory at all now. Just know that it is there and that it is tracking all the changes to the parent directory `snitch-sniffer`. 67 | 68 | -------------------------------------------------------------------------------- /en/step_7.md: -------------------------------------------------------------------------------- 1 | ## Adding your books 2 | 3 | - So you now have the magic school bag part, but you haven't yet added anything to it. That `README.md` file hasn't been placed into the bag yet. You need to tell Git that you want to add the `README.md` file to the repo. To do this you can simply type: 4 | 5 | ```bash 6 | git add README.md 7 | ``` 8 | 9 | Sometime it's easier to just add everything to the repo though, rather than adding individual files. To do this you can type: 10 | 11 | ```bash 12 | git add --all 13 | ``` 14 | 15 | - Now Git knows it needs to keep track of all the changes that happen to the `README.md` file. You can have a look at the status of your repo at any time by typing the following: 16 | 17 | ```bash 18 | git status 19 | ``` 20 | 21 | You should see something like this 22 | 23 | ```bash 24 | On branch master 25 | 26 | Initial commit 27 | 28 | Changes to be committed: 29 | (use "git rm --cached ..." to unstage) 30 | 31 | new file: README.md 32 | ``` 33 | 34 | - The above response is telling you that the `README.md` file has not yet been **committed**. This means that although Git knows about the file, it doesn't yet have any of the file's contents stored. The simplest way to do a commit is by typing: 35 | 36 | ```bash 37 | git commit -am "add README.md" 38 | ``` 39 | 40 | This commits all changes you have made in the directory to the Git repo, and adds a message saying what you did. The message can be anything really, but it's best to keep it fairly short yet descriptive of what you changed. 41 | 42 | -------------------------------------------------------------------------------- /en/step_8.md: -------------------------------------------------------------------------------- 1 | ## Adding more books and travelling in time. 2 | 3 | - Now that you have set up your repo, it's time to get on with the project. Here, two new files have been created: `snitch-sniffer.py` and `quidditch-rules.json`. Typing `ls` reveals those files. 4 | 5 | ```bash 6 | README.md quidditch-rules.json snitch-sniffer.py 7 | ``` 8 | 9 | - The new files need to be added to the Git repo and then committed. 10 | 11 | ```bash 12 | git add --all 13 | git commit -am 'add json rules and python program' 14 | ``` 15 | 16 | - Then you carry on working on your code for a bit. Every time you make a significant change to the file, you can perform a new commit. 17 | 18 | ```bash 19 | git commit -am 'finish find function' 20 | ``` 21 | 22 | - Now imagine that you've made a horrible mistake. You've been working for a while and you've deleted your `find_snitch()` function, and then performed a commit. With Git, it's easy to go back in time and restore an earlier version of any of your files. Let's first look at the commit history of the file. 23 | 24 | ```bash 25 | git log snitch-sniffer.py 26 | ``` 27 | 28 | - This produces something like this: 29 | 30 | ```bash 31 | commit 12c4c693e95438ceadcf3f4fb39c83ce1ade712f 32 | Author: Harry Potter 33 | Date: Fri Mar 3 20:27:17 2017 +0000 34 | 35 | delete find function 36 | 37 | commit 5fd772a292c019a7cf3012b1156685280d4a7d2d 38 | Author: Harry Potter 39 | Date: Fri Mar 3 20:24:52 2017 +0000 40 | 41 | finish find function 42 | 43 | commit 127545c19794b5fe869dd22d0cf57bf8820c5794 44 | Author: Harry Potter 45 | Date: Fri Mar 3 20:20:18 2017 +0000 46 | 47 | add json rules and python program 48 | ``` 49 | 50 | - You can see that in that last commit (the one at the top) was where the function was deleted. Luckily the commit message has made it easy to see what was done, which is why commit messages are important. However, typing `git log -p snitch-sniffer.py` would have actually shown the changed contents of the file, if the commit message wasn't clear enough. 51 | 52 | - You can now get back the version of the file from the commit before. The long string of characters after the word 'commit' is called a hash, and is used by Git to keep track of files. In this case, the commit that needs to be restored is `5fd772a292c019a7cf3012b1156685280d4a7d2d`. So typing the following will get the file back to the way it was: 53 | 54 | ```bash 55 | git checkout 5fd772a292c019a7cf3012b1156685280d4a7d2d snitch-sniffer.py 56 | ``` 57 | 58 | - The file will be restored and you can now commit this change. 59 | 60 | ```bash 61 | git commit -am 'restore find function' 62 | ``` 63 | 64 | -------------------------------------------------------------------------------- /en/step_9.md: -------------------------------------------------------------------------------- 1 | ## Making major changes 2 | 3 | Imagine you're talking to your friend about your amazing project, and they have a really cool idea for some changes you could make to improve it. Your friend suggests using [Lidar](https://en.wikipedia.org/wiki/Lidar) rather than ultrasonic sensors. The changes are quite large, though, and you're worried that if you make them, you might break the project. You could make a copy of the directory and start working on this copy, but to keep using Git you'd have to make an entirely new repo. This could all get quite confusing. Luckily, Git has a feature called **branches**; using a branch allows you to make copies without losing or altering your original work. 4 | 5 | - First, you can have a look at your repo's current status. 6 | 7 | ```bash 8 | git status 9 | ``` 10 | 11 | This should show something like this: 12 | 13 | ```bash 14 | On branch master 15 | nothing to commit, working directory clean 16 | ``` 17 | 18 | - Now you can make a new branch in the repo, which lets you work on your amazing new adaption. 19 | 20 | ```bash 21 | git checkout -b lidar-version 22 | ``` 23 | 24 | - Now `git status` will show you something like this: 25 | 26 | ```bash 27 | On branch lidar-version 28 | nothing to commit, working directory clean 29 | ``` 30 | 31 | This tells you that you are on the `lidar-version` branch. To view all the branches in your repo, you can type `git branch` which will show something like this: 32 | 33 | ```bash 34 | * lidar-version 35 | master 36 | ``` 37 | 38 | - You can now work on the lidar-version branch without altering your master branch. If you try out the new approach and find it doesn't work, you can simply delete the branch using `git branch -D lidar-version`. However, if it all works well, you can merge the branch back into your master branch. 39 | 40 | - First, you'll need to make sure all your changes are committed and then switch back to the master branch. 41 | 42 | ```bash 43 | git checkout master 44 | ``` 45 | - Then you can merge the version into the master branch 46 | 47 | ```bash 48 | git merge lidar-version 49 | ``` 50 | - **Warning**: you can cause problems with a merge if you're working on two branches at the same time, as Git won't know which changes are the ones you want to keep. For this reason, it's best to just work on one branch at a time. 51 | 52 | --------------------------------------------------------------------------------