From 31312246fa60f35f5348294d1a74f404f27d7e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rabea=20M=C3=BCller?= Date: Thu, 12 Oct 2023 15:56:04 +0200 Subject: [PATCH] Add instructions for installing, clone, add, commit with git --- 3-2-version-control.qmd | 111 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/3-2-version-control.qmd b/3-2-version-control.qmd index faf35ef..45ca34b 100644 --- a/3-2-version-control.qmd +++ b/3-2-version-control.qmd @@ -33,6 +33,117 @@ Learning Git can be daunting 🙀. Historically it was developed by software eng That makes it particularly useful for us when writing code, but it can also feel a bit too nerdy in the beginning. I promise though, once you've got the hang of it, you'll love it! +### Installing git on your computer 💻 + +Depending on the system you are working on, there are different ways to install git. + +For the latest stable version for Linux Ubuntu run this command in your terminal: + +```bash +apt-get install git +``` +If you are on Mac you can use homebrew to install it in your terminal. +Install [homebrew](https://brew.sh/) if you don't already have it, then type: + +```bash +brew install git +``` + +If you are working on Windows, I recommend installing Git Bash. This provides you with a terminal where you can work similarly to the terminal on Mac and Linux, using the same commands. Git Bash also automatically installs Git for you. You can download Git for Windows [here](https://gitforwindows.org/). + +You can visit [git-scm.com](https://git-scm.com/downloads) to get more information on how you can download git for your system. + +For R users, I recommend following [these](https://gitlab.com/HeidiSeibold/setup-git-rstudio-gitlab) instructions. + +### Create a new Repository on GitHub + +**Sign in to GitHub:** + +Open your browser, go to [GitHub](https://github.com/), and sign in to your GitHub account. If you don't have an account, you can create one by clicking on the "Sign up for GitHub" button. + +**Create a New Repository:** + +In the upper-right corner of any page, click on the `+` icon and select "New repository." +Alternatively, on your GitHub profile page, click on the "Repositories" tab, and then click the green "New" button. + +**Fill out the Repository Information:** + +- Enter a **Repository name**: Choose a name for your repository. This name will be part of your repository's URL. + +- Enter a **Description**: Optionally, you can add a description of your repository. + +- Choose **Public** or **Private**: Decide whether you want your repository to be public (visible to everyone) or private (accessible only to people you specify). + +- Initialize this repository with a **README**: Check this option to create a README file for your repository. A README file provides information about your project. + +- Choose a **.gitignore** file: If your project involves specific programming languages or frameworks, you can select a `.gitignore` template to exclude certain files from version control. You don't have to it for now. + +- Choose a **license**: If you want to add an open-source license to your repository, you can choose one from the provided options. You don't have to it for now. + +**Create the Repository:** +- Click the green "Create repository" button. Your new repository is now created. + +### Clone a GitHub Repository to your local machine + +I will show you how to clone a repository with ssh key. When you are on Github in your repository and select the green button `<> code`, you can choose https or ssh under the cloning points. If you choose https you have to identify yourself later with your GitHub password. The SSH key is another authentication method that is more secure in comparison. If you want to know how to create an SSH key pair, check [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent). + +**Clone GitHub Repository with SSH URL:** + +Open the terminal on your computer. + +Use the `git clone` command with the SSH URL of your GitHub repository to clone your repository to your local machine: + +```bash +git clone git@github.com:username/repository.git +``` + +Make sure to replace `username` with your GitHub username and `repository` with your repository name. + +Navigate into the newly created directory: + +```bash +cd repository +``` + +**Make Changes:** + +Add files, modify existing files, or create new files in your local repository as needed. + +**Check Status and Stage Changes:** + +Check the status of your repository to see which files have been changed: + +```bash +git status +``` + +Stage the changed files: + +```bash +git add . +``` + +**Commit Changes:** + +Commit the changes with a descriptive message: + +```bash +git commit -m "Description of the changes made" +``` + +Replace `"Description of the changes made"` with a brief description of the changes you made. + +**Push Changes to GitHub:** + +Push your changes to your GitHub repository: + +```bash +git push origin main +``` + +After this step is successful, your changes are published to your GitHub repository! 🎉 + + ### Other version control systems There are many other ways of doing version control out there.