diff --git a/.gitignore b/.gitignore index b8ab706287..ea0308dd22 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,5 @@ vendor/ .docker-vendor/ Gemfile.lock .*history + +.vscode diff --git a/config.yaml b/config.yaml index 79e2ae019c..833e19f3fd 100644 --- a/config.yaml +++ b/config.yaml @@ -62,6 +62,7 @@ episodes: - 01-basics.md - 02-setup.md - 03-create.md +- 09-branches.md - 04-changes.md - 05-history.md - 06-reverting-changes.md @@ -69,7 +70,6 @@ episodes: - Break.md - 07-github.md - 08-github-interface.md -- 09-branches.md - 10-pull-requests.md - End.md - 10-open.md diff --git a/episodes/03-create.md b/episodes/03-create.md index d46855485e..64ea2713c8 100644 --- a/episodes/03-create.md +++ b/episodes/03-create.md @@ -117,6 +117,65 @@ $ fcm info If you are using a different version of `git`, the exact wording of the output might be slightly different. +## Initial Commit + +As soon as you initialise your repository +you should make an initial commit. +All repositories should have a `README` file +which outlines the purpose of the repository +and other useful information. +For now we will create the file with just +the repository name, **Weather** as the title: + +```bash +$ echo "# Weather" > README.md +$ cat README.md +``` + +```output +# Weather +``` + +Now add and commit the `README.md` file +using the `git add` and `git commit` commands: + +```bash +$ git add README.md +$ git commit -m "Initial commit" +``` + +```output +[main (root-commit) 6f12a47] Initial commit + 1 file changed, 1 insertion(+) + create mode 100644 README.md +``` + +You've just added your first file to be version controlled with Git! +This first commit is the special **root-commit**. +It is the start of your version control history and +like all commits has been given a unique alphanumeric hash (`6f12a47`). +In the next few episodes you will explore +tracking changes with `git add` and `git commit` in detail, +and learn how to inspect your repositories history. + +::: callout + +### README Files + +All repositories should have a `README` file. +The `README` file describes what is in your repository. +The [makeareadme](https://www.makeareadme.com/) website is a great +resource for `README` templates and inspiration. + +The `README.md` file we added is a [Markdown](https://www.markdownguide.org/basic-syntax/) +file. +Markdown is a simple markup language and +GitHub can render Markdown files natively. +The GitHub documentation pages on [Writing on GitHub](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) +have more info on writing in Markdown for GitHub. + +::: + ::::::::::::::::::::::::::::::::::::::: challenge ## Places to Create Git Repositories diff --git a/episodes/04-changes.md b/episodes/04-changes.md index ce286e77b8..ca58b88020 100644 --- a/episodes/04-changes.md +++ b/episodes/04-changes.md @@ -20,28 +20,14 @@ exercises: 0 :::::::::::::::::::::::::::::::::::::::::::::::::: -::: caution - -### Committing to Main - -In this lesson you will be making changes on `main`. -The `main` branch normally contains stable production code and -should **NEVER** be committed to directly. -In the later GitHub and Branches episodes you will learn -a basic workflow to ensure you never commit to main; -and learn what to do when you accidentally commit to main. - -::: - -First let's make sure we're still in the right directory. -You should be in the `weather` directory. +First let's make sure we're still on the right branch. +You should be on the `forecast` branch: ```bash -$ cd ~/Desktop/weather +$ git switch forecast ``` -Let's create a file called `forecast.md` that contains the basic structure to -have a recipe. +Let's create a file called `forecast.md` that contains a basic weather forecast. We'll use `nano` to edit the file; you can use whatever editor you like. In particular, this does not have to be the `core.editor` you set globally earlier. But remember, the steps to create create or edit a new file will depend on the editor you choose (it might not be nano). For a refresher on text editors, check out ["Which Editor?"](https://swcarpentry.github.io/shell-novice/03-create.html#which-editor) in [The Unix Shell](https://swcarpentry.github.io/shell-novice/) lesson. @@ -54,7 +40,9 @@ Type the text below into the `forecast.md` file: ```output # Forecast + ## Today + Cloudy with a chance of pizza. ``` @@ -77,7 +65,9 @@ $ cat forecast.md ```output # Forecast + ## Today + Cloudy with a chance of pizza. ``` @@ -89,7 +79,7 @@ $ git status ``` ```output -On branch main +On branch forecast No commits yet @@ -116,7 +106,7 @@ $ git status ``` ```output -On branch main +On branch forecast No commits yet @@ -124,7 +114,6 @@ Changes to be committed: (use "git rm --cached ..." to unstage) new file: forecast.md - ``` Git now knows that it's supposed to keep track of `forecast.md`, @@ -137,8 +126,8 @@ $ git commit -m "Create a md file with the forecast" ``` ```output -[main (root-commit) f22b25e] Create a md file with the forecast - 1 file changed, 3 insertions(+) +[forecast f22b25e] Create a md file with the forecast + 1 file changed, 5 insertions(+) create mode 100644 forecast.md ``` @@ -192,6 +181,16 @@ $ fcm commit ::: +Our repository now looks like this: + +```mermaid + gitGraph + accDescr {A git graph showing the root-commit on the main branch and a new forecast branch, branching off the root-commit, with one commit.} + commit id: 'Initial commit' + branch forecast + commit id: 'Create a md file with the forecast' +``` + If we run `git status` now: ```bash @@ -199,7 +198,7 @@ $ git status ``` ```output -On branch main +On branch forecast nothing to commit, working tree clean ``` @@ -209,7 +208,8 @@ it tells us everything is up to date. ## Where Are My Changes? -If we run `ls` at this point, we will still see just one file called `forecast.md`. +If we run `ls` at this point, we will still see just our two files, +`README.md` and `forecast.md`. That's because Git saves information about files' history in the special `.git` directory mentioned earlier so that our filesystem doesn't become cluttered @@ -229,9 +229,13 @@ $ cat forecast.md ```output # Forecast + ## Today + Cloudy with a chance of pizza. + ## Tomorrow + Morning rainbows followed by light showers. ``` @@ -243,7 +247,7 @@ $ git status ``` ```output -On branch main +On branch forecast Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) @@ -273,11 +277,13 @@ diff --git a/forecast.md b/forecast.md index df0654a..315bf3a 100644 --- a/forecast.md +++ b/forecast.md -@@ -1,3 +1,5 @@ - # Forecast +@@ -3,3 +3,7 @@ ## Today + Cloudy with a chance of pizza. ++ +## Tomorrow ++ +Morning rainbows followed by light showers. ``` @@ -329,7 +335,7 @@ $ git commit -m "Add tomorrows forecast to forecast.md" ``` ```output -On branch main +On branch forecast Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) @@ -349,8 +355,8 @@ $ git commit -m "Add tomorrows forecast to forecast.md" ``` ```output -[main 34961b1] Add tomorrows forecast to forecast.md - 1 file changed, 2 insertions(+) +[forecast 34961b1] Add tomorrows forecast to forecast.md + 1 file changed, 4 insertions(+) ``` Git insists that we add files to the set we want to commit @@ -418,6 +424,17 @@ $ fcm commit ::: +Our repository now looks like this: + +```mermaid + gitGraph + accDescr {A git graph showing the root-commit on the main branch and a new forecast branch, branching off the root-commit, with two commits.} + commit id: 'Initial commit' + branch forecast + commit id: 'Create a md file with the forecast' + commit id: 'Add tomorrows forecast to forecast.md' +``` + Let's watch as our changes to a file move from our editor to the staging area and into long-term storage. @@ -431,9 +448,13 @@ $ cat forecast.md ```output # Forecast + ## Today + Cloudy with a chance of Sun. + ## Tomorrow + Morning rainbows followed by light showers. ``` @@ -446,13 +467,15 @@ diff --git a/forecast.md b/forecast.md index 315bf3a..b36abfd 100644 --- a/forecast.md +++ b/forecast.md -@@ -1,5 +1,5 @@ - # Forecast +@@ -2,7 +2,7 @@ + ## Today + -Cloudy with a chance of pizza. +Cloudy with a chance of Sun. + ## Tomorrow - Morning rainbows followed by light showers. + ``` So far, so good: @@ -481,13 +504,15 @@ diff --git a/forecast.md b/forecast.md index 315bf3a..b36abfd 100644 --- a/forecast.md +++ b/forecast.md -@@ -1,5 +1,5 @@ - # Forecast +@@ -2,7 +2,7 @@ + ## Today + -Cloudy with a chance of pizza. +Cloudy with a chance of Sun. + ## Tomorrow - Morning rainbows followed by light showers. + ``` it shows us the difference between @@ -500,7 +525,7 @@ $ git commit -m "Modify the forecast to add a chance of Sun" ``` ```output -[main 005937f] Modify the forecast to add a chance of Sun +[forecast 005937f] Modify the forecast to add a chance of Sun 1 file changed, 1 insertion(+), 1 deletion(-) ``` @@ -511,10 +536,22 @@ $ git status ``` ```output -On branch main +On branch forecast nothing to commit, working tree clean ``` +Our repository now looks like this: + +```mermaid + gitGraph + accDescr {A git graph showing the root-commit on the main branch and a new forecast branch, branching off the root-commit, with three commits.} + commit id: 'Initial commit' + branch forecast + commit id: 'Create a md file with the forecast' + commit id: 'Add tomorrows forecast to forecast.md' + commit id: 'Modify the forecast to add a chance of Sun' +``` + ::::::::::::::::::::::::::::::::::::::::: callout ## Word-based diffing @@ -669,10 +706,14 @@ $ cat forecast.md ```output # Forecast + ## Today + Cloudy with a chance of sun. Mild temperatures around 16 °C. + ## Tomorrow + Morning rainbows followed by light showers. ``` @@ -710,7 +751,7 @@ $ git commit -m "Add in the temperature to the forecast and create the weather a ``` ```output -[main cc127c2]Add in the temperature to the forecast and create the weather atlas file +[forecast cc127c2] Add in the temperature to the forecast and create the weather atlas file 2 files changed, 6 insertions(+) create mode 100644 atlas.md ``` diff --git a/episodes/05-history.md b/episodes/05-history.md index e9f1146a4a..f269c8be56 100644 --- a/episodes/05-history.md +++ b/episodes/05-history.md @@ -29,7 +29,7 @@ $ git log ``` ```output -commit cdb7fa654c3f5aee731a655e57f2ba74d9c74582 (HEAD -> main) +commit cdb7fa654c3f5aee731a655e57f2ba74d9c74582 (HEAD -> forecast) Author: Joanne Simpson Date: Mon Nov 4 18:35:21 2024 +0000 @@ -44,6 +44,8 @@ the short identifier printed by the `git commit` command earlier), the commit's author, when it was created, and the log message Git was given when the commit was created. +The output above only shows the latest commit in the log for brevity, +you should see all your commits! ::: spoiler @@ -90,7 +92,7 @@ $ git log -1 ``` ```output -commit cdb7fa654c3f5aee731a655e57f2ba74d9c74582 (HEAD -> main) +commit cdb7fa654c3f5aee731a655e57f2ba74d9c74582 (HEAD -> forecast) Author: Joanne Simpson Date: Mon Nov 4 18:35:21 2024 +0000 @@ -105,7 +107,7 @@ $ git log --oneline ``` ```output -cdb7fa6 (HEAD -> main) Add in the temperature to the forecast and create the weather atlas file +cdb7fa6 (HEAD -> forecast) Add in the temperature to the forecast and create the weather atlas file 62a9457 Modify the forecast to add a chance of Sun d3e4637 Add tomorrows forecast to forecast.md 590c40c Create a md file with the forecast @@ -122,7 +124,7 @@ $ git log --oneline --graph ``` ```output -* cdb7fa6 (HEAD -> main) Add in the temperature to the forecast and create the weather atlas file +* cdb7fa6 (HEAD -> forecast) Add in the temperature to the forecast and create the weather atlas file * 62a9457 Modify the forecast to add a chance of Sun * d3e4637 Add tomorrows forecast to forecast.md * 590c40c Create a md file with the forecast @@ -138,7 +140,8 @@ directory by using the identifier `HEAD`. We've been adding small changes at a time to `forecast.md`, so it's easy to track our progress by looking, so let's do that using our `HEAD`s. Before we start, -let's make a change to `forecast.md`, adding yet another line. +let's make a change to `forecast.md`, adding yet another line with +**an ill-considered change**. ```bash $ nano forecast.md @@ -147,10 +150,14 @@ $ cat forecast.md ```output # Forecast + ## Today + Cloudy with a chance of sun. Mild temperatures around 16 °C. + ## Tomorrow + Morning rainbows followed by light showers. An ill-considered change. ``` @@ -166,9 +173,11 @@ diff --git a/forecast.md b/forecast.md index b36abfd..0848c8d 100644 --- a/forecast.md +++ b/forecast.md -@@ -4,3 +4,4 @@ Cloudy with a chance of sun. +@@ -8,3 +8,4 @@ Mild temperatures around 16 °C. + ## Tomorrow + Morning rainbows followed by light showers. +An ill-considered change. ``` @@ -195,13 +204,16 @@ diff --git a/forecast.md b/forecast.md index df0654a..b36abfd 100644 --- a/forecast.md +++ b/forecast.md -@@ -1,5 +1,7 @@ - # Forecast +@@ -2,8 +2,10 @@ + ## Today + -Cloudy with a chance of pizza. +Cloudy with a chance of sun. +Mild temperatures around 16 °C. + ## Tomorrow + Morning rainbows followed by light showers. +An ill-considered change. ``` @@ -224,11 +236,13 @@ diff --git a/forecast.md b/forecast.md index d8bc6ce..5b5d97e 100644 --- a/forecast.md +++ b/forecast.md -@@ -1,3 +1,5 @@ - # Forecast +@@ -3,3 +3,7 @@ ## Today + Cloudy with a chance of pizza. ++ +## Tomorrow ++ +Morning rainbows followed by light showers. ``` @@ -247,7 +261,7 @@ These are unique IDs for the changes, and "unique" really does mean unique: every change to any set of files on any computer has a unique 40-character identifier. -Our first commit was given the ID +Our first commit on the `forecast` branch was given the ID `f22b25e3233b4645dabd0d81e651fe074bd8e73b`, so let's try this: @@ -260,13 +274,16 @@ diff --git a/forecast.md b/forecast.md index df0654a..93a3e13 100644 --- a/forecast.md +++ b/forecast.md -@@ -1,3 +1,7 @@ - # Forecast +@@ -2,4 +2,10 @@ + ## Today + -Cloudy with a chance of pizza. +Cloudy with a chance of sun. +Mild temperatures around 16 °C. ++ +## Tomorrow ++ +Morning rainbows followed by light showers. +An ill-considered change. ``` @@ -284,13 +301,16 @@ diff --git a/forecast.md b/forecast.md index df0654a..93a3e13 100644 --- a/forecast.md +++ b/forecast.md -@@ -1,3 +1,7 @@ - # Forecast +@@ -2,4 +2,10 @@ + ## Today + -Cloudy with a chance of pizza. +Cloudy with a chance of sun. +Mild temperatures around 16 °C. ++ +## Tomorrow ++ +Morning rainbows followed by light showers. +An ill-considered change. ``` @@ -303,6 +323,7 @@ What is the output of the last command in ```bash $ cd weather +$ git switch -c add_CMIP_data $ echo "Global Climate Data" > CMIP7.md $ git add CMIP7.md $ echo "Data from the 7th model intercomparison project" >> CMIP7.md diff --git a/episodes/06-ignore.md b/episodes/06-ignore.md index fa8fb3b1dc..22bf49a737 100644 --- a/episodes/06-ignore.md +++ b/episodes/06-ignore.md @@ -34,7 +34,7 @@ $ git status ``` ```output -On branch main +On branch forecast Untracked files: (use "git add ..." to include in what will be committed) @@ -76,7 +76,7 @@ $ git status ``` ```output -On branch main +On branch forecast Untracked files: (use "git add ..." to include in what will be committed) @@ -93,12 +93,12 @@ Let's add and commit `.gitignore`: ```bash $ git add .gitignore -$ git commit -m "Ignore png files and the data folder." +$ git commit -m "Ignore png files and the data folder" $ git status ``` ```output -On branch main +On branch forecast nothing to commit, working tree clean ``` @@ -124,7 +124,7 @@ $ git status --ignored ``` ```output -On branch main +On branch forecast Ignored files: (use "git add -f ..." to include in what will be committed) diff --git a/episodes/06-reverting-changes.md b/episodes/06-reverting-changes.md index 6393db3a42..855933540c 100644 --- a/episodes/06-reverting-changes.md +++ b/episodes/06-reverting-changes.md @@ -31,7 +31,7 @@ $ git status ``` ```output -On branch main +On branch forecast Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) @@ -50,10 +50,14 @@ $ cat forecast.md ```output # Forecast + ## Today + Cloudy with a chance of sun. Mild temperatures around 16 °C. + ## Tomorrow + Morning rainbows followed by light showers. ``` @@ -90,7 +94,9 @@ $ cat forecast.md ```output # Forecast + ## Today + Cloudy with a chance of pizza. ``` @@ -99,7 +105,7 @@ $ git status ``` ```output -On branch main +On branch forecast Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) @@ -119,10 +125,14 @@ $ cat forecast.md ```output # Forecast + ## Today + Cloudy with a chance of sun. Mild temperatures around 16 °C. + ## Tomorrow + Morning rainbows followed by light showers. ``` diff --git a/episodes/07-github.md b/episodes/07-github.md index 46057acf18..08810a5d2f 100644 --- a/episodes/07-github.md +++ b/episodes/07-github.md @@ -320,38 +320,48 @@ Good! This output confirms that the SSH key works as intended. We are now ready ## 4\. Push local changes to a remote -Now that authentication is setup, we can return to the remote. This command will push the changes from +Now that authentication is setup, we can return to the local repository. +Ensure you are on the `main` branch: + +```bash +$ git switch main +``` + +This command will push our main branch on our local repository to the repository on GitHub: ```bash -$ git push origin main +$ git push +``` + +```output +fatal: The current branch main has no upstream branch. +To push the current branch and set the remote as upstream, use + + git push --set-upstream origin main + ``` +Git is telling us it doesn't know what branch we want to push +our local `main` branch to on GitHub. +We can tell Git this by setting the upstream `origin` branch +to also be named `main`. + If you entered a passphrase when creating an shh key you will be prompted for it. ```output Enumerating objects: 16, done. Counting objects: 100% (16/16), done. -Delta compression using up to 8 threads. -Compressing objects: 100% (11/11), done. -Writing objects: 100% (16/16), 1.45 KiB | 372.00 KiB/s, done. -Total 16 (delta 2), reused 0 (delta 0) -remote: Resolving deltas: 100% (2/2), done. -To https://github.com/mo-eormerod/weather.git +Delta compression using up to 4 threads +Compressing objects: 100% (13/13), done. +Writing objects: 100% (16/16), 1.69 KiB | 216.00 KiB/s, done. +Total 16 (delta 1), reused 0 (delta 0), pack-reused 0 +remote: Resolving deltas: 100% (1/1), done. +To github.com:mo-eormerod/weather.git * [new branch] main -> main +branch 'main' set up to track 'origin/main'. ``` -You can avoid typing `origin main` by setting the upstream remote branch -for the local branch `main`: - -```bash -git push --set-upstream origin main -``` - -This command run from the local repositories main branch tells git that when -we run `git push` we want to push to `origin`'s, the remote GitHub repository, -`main` branch. - ::: callout ### Automatically set the upstream branch @@ -431,18 +441,18 @@ command, and is used to associate the current branch with a remote branch so that the `git pull` command can be used without any arguments. To do this, simply use `git push -u origin main` once the remote has been set up. +Here, we are telling Git to push the branch +to the origin (GitHub) repositories `main` branch. :::::::::::::::::::::::::::::::::::::::::::::::::: We can pull changes from the remote repository to the local one as well: ```bash -$ git pull origin main +$ git pull ``` ```output -From https://github.com/mo-eormerod/weather - * branch main -> FETCH_HEAD Already up-to-date. ``` diff --git a/episodes/09-branches.md b/episodes/09-branches.md index a139149f1e..623aab2f16 100644 --- a/episodes/09-branches.md +++ b/episodes/09-branches.md @@ -23,10 +23,11 @@ Branching is a feature available in most modern version control systems. Branching in other version control systems can be an expensive operation in both time and disk space. In git, branches are a part of your everyday development process. -So far we have been working on the `main` branch. -From this point on you should **NEVER** commit to `main`. -When you want to add a new feature or fix a bug—no matter how big or how -small — you create a new branch for your changes. +So far we have been working on the `main` branch +and have made one commit, the **root-commit**. +Committing the initial **root-commit** is the only time you should commit to `main`. +When you want to add a new change or fix a bug, no matter how big or how +small, you create a new branch for your changes. This makes it harder for unstable code to get merged into the main code base, and it gives you the chance to clean up your branch history before merging it into the main branch. @@ -37,46 +38,12 @@ config: showCommitLabel: false --- gitGraph - accDescr {A git graph showing four branches including the default - main branch. - Each circle is a commit. - A circle with an outline but no fill colour is a merge commit - where one branch has been merged into another. - The two feature branches and the bug_fix branch - all branch off of main at the same commit. - The bug_fix and small_feature branches - are merged back into main after - being developed on their branches. - The large_feature branch merges in the - changes to main to fix any conflicts - before the feature is ready to be merged - back into the main branch via a pull request.} - commit - commit - branch bug_fix - checkout main - branch small_feature - checkout main - branch large_feature - checkout bug_fix - commit - checkout large_feature - commit - checkout main - merge bug_fix - checkout small_feature - commit - checkout large_feature - commit - checkout small_feature - commit - checkout main - merge small_feature - checkout large_feature - commit - merge main + accDescr {A git graph showing the root-commit on the main branch and a new forecast branch with one commit branched off the root-commit. This branch is then merged back into main via a merge commit on GitHub.} + commit id: '6f12a47' + branch forecast + commit id: '8136c6f Add in a seasonal forecasts file' checkout main - merge large_feature + merge forecast ``` If you completed the pre-workshop [setup instructions for git autocomplete](learners/setup.md#git-autocomplete) @@ -86,8 +53,7 @@ you should see the current branch, `main`, in your terminal prompt: [~/Desktop/weather]:(main =)$ ``` -The `git status` command we have been using throughout earlier episodes -also shows us the current branch: +The `git status` command also shows us the current branch: ```bash $ git status @@ -100,41 +66,28 @@ Your branch is up to date with 'origin/main'. nothing to commit, working tree clean ``` -::: callout - -### What are Branches? - -Remember a git commit is a snapshot of files, it has no branch information. Commits simply point to the previous 'parent' commits, forming a graph, and a branch is nothing more than a reference (pointer) to a commit. - -More practically you can think of a branch as a list of commits that are accessible from the branch's reference but not from main. - -::: - ## Creating Branches Our current repository looks something like this: ```mermaid gitGraph - accDescr {A git graph showing three commits to the main branch.} - commit id: '41c775b' - commit id: 'a489b1f' - commit id: 'cdb7fa6' + accDescr {A git graph showing one commit, the root-commit on the main branch.} + commit id: '6f12a47' ``` -All our commits, the circles with commit IDs, are on the main branch, -the top horizontal line. - -Say we want to add a longer seasonal forecast to our repository. -We should make a branch to develop our changes on. +To make any changes we should create a new branch. There are several ways to create a branch and switch to the new branch. While it's good to be aware of all these different methods we recommend using `git switch -c`. -You should ensure the branch has a suitable name +You should ensure the branch has a suitable unique name which will help you identify what the branch is for; even after several months of inactivity. +We are going to add a weather forecast to our repository +so our branch will be named **forecast**: + ::: tab ### git switch -c @@ -144,11 +97,11 @@ months of inactivity. switches you to a new branch: ```bash -$ git switch -c seasonal-forecast +$ git switch -c forecast ``` ```output -Switched to branch 'seasonal-forecast' +Switched to branch 'forecast' ``` ### git branch @@ -156,18 +109,18 @@ Switched to branch 'seasonal-forecast' To create a new branch use `git branch `: ```bash -$ git branch seasonal-forecast +$ git branch forecast ``` Now run `git status` and you will see you're still on the main branch. To navigate between branches use `git switch `: ```bash -$ git switch seasonal-forecast +$ git switch forecast ``` ```output -Switched to branch 'seasonal-forecast' +Switched to branch 'forecast' ``` ### git checkout -b @@ -177,11 +130,11 @@ The `git checkout` command can also be used to navigate between branches. creates and switches you to the new branch: ```bash -$ git checkout -b seasonal-forecast +$ git checkout -b forecast ``` ```output -Switched to branch 'seasonal-forecast' +Switched to branch 'forecast' ``` ::: @@ -193,20 +146,18 @@ $ git status ``` ```output -On branch seasonal-forecast +On branch forecast nothing to commit, working tree clean ``` -We haven't added anything yet so there is nothing to commit and our -repository looks like this: +Now we have created but not committed anything to this new branch +so our repository looks like this: ```mermaid gitGraph - accDescr {A git graph showing three commits to the main branch and a new seasonal-forecast branch with no commits.} - commit id: '41c775b' - commit id: 'a489b1f' - commit id: 'cdb7fa6' - branch seasonal-forecast + accDescr {A git graph showing the root-commit on the main branch and a new forecast branch with no commits.} + commit id: '6f12a47' + branch forecast ``` If we run `git branch` we can see the branches that exist in our repository. @@ -216,17 +167,38 @@ $ git branch ``` ```output +* forecast main -* seasonal-forecast ``` -The `*` indicates we are now on the `seasonal-forecast` branch. +The `*` indicates we are now on the `forecast` branch. + +::: caution + +### Unique Branch Names + +To avoid creating a branch with the same name +as a collaborators branch it is common to prefix +the branch name with an Issue (ticket) number. + +You might choose to include your initials or +username in your branch although this is less +common than an Issue number. + +Separate words in branch names with `-` or `_` +depending on your teams working practices. +The [Git & GitHub Working Practices lesson](https://www.astropython.com/git-working-practices/), +which you can take after this introductory lesson, +will help you choose the working practices +that are right for you and your team. + +::: ::::::::::::::::::::::::::::::::::::: challenge ## Switching Between Branches -How would you switch back to the `main` branch from the `seasonal-forecast` branch? +How would you switch back to the `main` branch from the `forecast` branch? :::::::::::::::: solution @@ -290,52 +262,6 @@ git branch ::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::: -## Developing on a Branch - -Developing your changes on a branch is exactly the same as you practised -in earlier episodes. -Let's add a `seasonal-forecast.md` file: - -```bash -$ nano seasonal-forecast.md -$ cat seasonal-forecast.md -``` - -```output -# Seasonal Forecast - -- Winter is cold -- Summer is hot -``` - -And commit these changes: - -```bash -$ git add seasonal-forecast.md -$ git commit -m "Add in a seasonal forecasts file" -``` - -```output -[seasonal-forecast 8136c6f] Add in a seasonal forecasts file - 1 file changed, 4 insertions(+) - create mode 100644 seasonal-forecast.md -``` - -Now our repository looks like this: - -```mermaid - gitGraph - accDescr {A git graph showing three commits to the main branch and a new seasonal-forecast branch with one commit branched of the HEAD of main.} - commit id: '41c775b' - commit id: 'a489b1f' - commit id: 'cdb7fa6' - branch seasonal-forecast - commit id: '8136c6f Add in a seasonal forecasts file' -``` - -In the next episode we will explore a simple workflow to merge these -changes back into the `main` branch using GitHub. - ## Deleting Branches A colleague of yours gets really excited about using branches and creates a new one: @@ -348,29 +274,24 @@ $ git switch -c shipping-forecast Switched to a new branch 'shipping-forecast' ``` -In their excitement they forgot to switch back to the `main` branch -before running the `git switch -c` command. -They have inadvertently branched off a branch that isn't `main`. -Running `git branch` with the `-vv` verbosity flag gives: +They then check their branches: ```bash $ git branch -vv ``` ```output - main 41c775b [origin/main] Ignore png files and the data folder. - seasonal-forecast 8136c6f Add in a seasonal forecasts file -* shipping-forecast 8136c6f Add in a seasonal forecasts file + forecast 6f12a47 Initial commit + main 6f12a47 Initial commit +* shipping-forecast 6f12a47 Initial commit ``` -The `shipping-forecast` output line references the same commit as the `seasonal-forecast` one! -This means the `shipping-forecast` branch was created from the `seasonal-forecast` branch at commit `8136c6f`. - -Sometimes it will make sense to branch off of branches that are not `main`. -In this case your colleague decides to delete the branch since they haven't made any commits to it yet. To delete a branch first switch to any other branch: +Your colleague decides to delete the branch +since today's shipping forecast isn't ready. +To delete a branch first switch to any other branch: ```bash -$ git switch main +$ git switch forecast ``` and then delete the branch with `git branch -d`: @@ -380,24 +301,41 @@ $ git branch -d shipping-forecast ``` ```output -error: The branch 'shipping-forecast' is not fully merged. -If you are sure you want to delete it, run 'git branch -D shipping-forecast'. +Deleted branch shipping-forecast (was 6f12a47). ``` -Notice our branch wasn't deleted! -Git is telling us we didn't merge our changes onto another branch and might lose commits. -Your colleague knows it is safe to delete the `shipping-forecast` branch -because it contains no commits. -They go ahead and run the suggested command with the `-D`, force delete, flag: +::: callout -```bash -$ git branch -D shipping-forecast +## Check your branch point + +Always switch to the branch you want to branch from, usually `main`, +or explicitly specify a branch point when creating new branches. +This helps avoid accidentally branching of a branch +which isn't `main` if you didn't mean to. + +Imagine a colleague has added more files to their `forecast` branch +and just created a `tidal-forecast` branch. + +They run: + +```git +$ git branch -vv ``` ```output -Deleted branch shipping-forecast (was 8136c6f). + forecast 8136c6f Add in a seasonal forecasts file + main 6f12a47 Initial commit +* tidal-forecast 8136c6f Add in a seasonal forecasts file ``` +Here the hash for the `tidal-forecast` branch is the same +as the `forecast` branch so `tidal-forecast` +is not branched off `main`. +If they meant to branch off `main` they should delete this branch, +and re-create it from the correct branch point. + +::: + ::::::::::::::::::::::::::::::::::::: challenge ## Deleting a branch that is checked out diff --git a/episodes/10-pull-requests.md b/episodes/10-pull-requests.md index bd5e871446..3a3c96e1ed 100644 --- a/episodes/10-pull-requests.md +++ b/episodes/10-pull-requests.md @@ -17,7 +17,9 @@ exercises: 15 :::::::::::::::::::::::::::::::::::::::::::::::::: -Pull requests are a great way to collaborate with others using GitHub. Instead of making changes directly to a repository you can suggest changes to a repository using a pull request. +Pull requests are a great way to collaborate with others using GitHub. +Instead of making changes directly to a repository +you can suggest changes to a repository using a pull request. Pull requests are where your changes go through the vital steps of code and science review. @@ -28,13 +30,13 @@ reduce the chance of human error when checking new code. ## Creating a Pull Request -In the last episode on branches we developed a change -on the `seasonal-forecast` branch. +In the previous episodes we developed our changes +on the `forecast` branch. Let's use a PR to merge these changes back into the `main` branch. -Make sure you are still on the `seasonal-forecast` branch: +Make sure you are still on the `forecast` branch: ```bash -$ git switch seasonal-forecast +$ git switch forecast ``` Now we can publish these changes to GitHub: @@ -45,16 +47,16 @@ $ git push Navigate to your `weather` GitHub repo. You should see a notification appear with the text -**`seasonal-forecast` had recent pushes**. +**`forecast` had recent pushes**. -![](fig/github_create_pr.png){alt='A screenshot of the weather repo showing the notification prompting us to Compare & pull request for the seasonal-forecast branch.'} +![](fig/github_create_pr.png){alt='A screenshot of the weather repo showing the notification prompting us to Compare & pull request for the forecast branch.'} Click on the green **Compare & pull request** button. -![](fig/github_create_pr_2.png){alt='A screenshot of the weather repo showing the creation of a pull request for the seasonal-forecast branch changes.'} +![](fig/github_create_pr_2.png){alt='A screenshot of the weather repo showing the creation of a pull request for the forecast branch changes.'} This page lets us create a new pull request from the -`seasonal-forecast` branch. +`forecast` branch. The title has been autofilled with the message of the last commit. You can see all the commits on the branch at the bottom of this page. @@ -80,7 +82,7 @@ aren't automatically assigned. Notice we've now moved to the **Pull Requests** tab. This is PR **#1** and underneath the title we see: -> wants to merge 1 commit into `main` from `seasonal-forecast` +> wants to merge 4 commits into `main` from `forecast` If you need to change the title or the branch you're merging into, in this case `main`, click on the **edit** button @@ -92,7 +94,7 @@ The PR has four tabs below the title section: - **Commits** shows all the commits we want to merge - **Checks** shows the output from any automated code and science checks - **Files Changed** shows a diff (difference) between the - branch with your changes, `seasonal-forecast`, + branch with your changes, `forecast`, and the target branch, `main`. At this point you should use the diff in the **Files changed** tab to check your changes. @@ -157,12 +159,12 @@ Then click on **Confirm squash and merge**. ![](fig/github_pr_closed.png){alt='A screenshot showing a closed pull request on the weather repository.'} The PR is now successfully merged into the `main` branch. -We can safely delete the `seasonal-forecast` branch from the GitHub repo. +We can safely delete the `forecast` branch from the GitHub repo. Click on the **Delete branch button**. ### Updating your Local Repo -The new `seasonal-forecast.md` file is currently only on the `main` branch in GitHub. +The new `forecast.md` file is currently only on the `main` branch in GitHub. We should pull the changes down to our local copy. Switch to the `main` branch: @@ -186,9 +188,11 @@ From github.com:mo-eormerod/weather 41c775b..49c845c main -> origin/main Updating 41c775b..49c845c Fast-forward - seasonal-forecast.md | 4 ++++ - 1 file changed, 4 insertions(+) - create mode 100644 seasonal-forecast.md + .gitignore | 2 ++ + forecast.md | 9 +++++++++ + 2 files changed, 11 insertions(+) + create mode 100644 .gitignore + create mode 100644 forecast.md ``` ::: callout @@ -225,7 +229,7 @@ From github.com:mo-ormerod/weather ### Cleaning up your Local Branches -We deleted our `seasonal-forecast` dev branch from GitHub +We deleted our `forecast` dev branch from GitHub but we still have a local copy. Let's tidy up by deleting it. To see all our branches including remote GitHub branches run: @@ -235,10 +239,10 @@ $ git branch -avv ``` ```output -* main 49c845c [origin/main] Add in a seasonal forecasts file (#1) - seasonal-forecast 8136c6f [origin/seasonal-forecast] Add in a seasonal forecasts file - remotes/origin/main 49c845c Add in a seasonal forecasts file (#1) - remotes/origin/seasonal-forecast 8136c6f Add in a seasonal forecasts file + forecast 13e0329 [origin/forecast] Ignore png files and the data folder +* main d1da035 [origin/main] #1 Add in a forecast file + remotes/origin/forecast 13e0329 Ignore png files and the data folder + remotes/origin/main d1da035 #1 Add in a forecast file ``` The first two branches are our local branches, the last two are the GitHub remotes. @@ -251,54 +255,47 @@ $ git remote prune origin ```ouput Pruning origin URL: git@github.com:mo-eormerod/weather.git - * [pruned] origin/seasonal-forecast + * [pruned] origin/forecast ``` Running `git branch -avv` again now shows: ```ouptut -* main 49c845c [origin/main] Add in a seasonal forecasts file (#1) - seasonal-forecast 8136c6f [origin/seasonal-forecast: gone] Add in a seasonal forecasts file - remotes/origin/main 49c845c Add in a seasonal forecasts file (#1) + forecast 13e0329 [origin/forecast: gone] Ignore png files and the data folder +* main d1da035 [origin/main] #1 Add in a forecast file + remotes/origin/main d1da035 #1 Add in a forecast file ``` -You can see the remote reference for the `seasonal-forecast` branch +You can see the remote reference for the `forecast` branch has been removed. -The second line with the local `seasonal-forecast` branch now has +The second line with the local `forecast` branch now has `gone` in the brackets referencing the remote branch. To delete our local branch run: ```bash -$ git branch -D seasonal-forecast +$ git branch -D forecast ``` Running `git branch -avv` again now shows: ```output -* main 49c845c [origin/main] Add in a seasonal forecasts file (#1) - remotes/origin/main 49c845c Add in a seasonal forecasts file (#1) +* main d1da035 [origin/main] #1 Add in a forecast file + remotes/origin/main d1da035 #1 Add in a forecast file ``` You've now successfully merged and tidied up after your first pull request. -Remember from now on always create a new branch and open a PR -when developing a new feature. -**NEVER** commit to the `main` branch. +Remember when making changes create a new branch +and open a PR, **NEVER** commit to the `main` branch. ::::::::::::::::::::::::::::::::::::: challenge -## Adding in a README.md file +## Adding in a seasonal-forecast.md file -All repositories should have a `README` file. -The `README` file describes what is in your repository. -The [makeareadme](https://www.makeareadme.com/) website is a great -resource for `README` templates and inspiration. - -Use the [makeareadme](https://www.makeareadme.com/) site or other resources -to add a `README.md` file to your repository: +Try adding in a seasonal forecast using the following steps: 1. Create a new branch with an appropriate name and switch to it -2. Create the `README.md` file +2. Create the `seasonal-forecast.md` file 3. Add and commit the new file 4. Push the changes to GitHub 5. Open a PR on GitHub @@ -311,37 +308,38 @@ to add a `README.md` file to your repository: 1. Create a new branch with an appropriate name and switch to it ```bash -$ git switch -c add-readme +$ git switch -c add-seasonal-forecast ``` ```output -Switched to a new branch 'add-readme' +Switched to a new branch 'add-seasonal-forecast' ``` -2. Create the `README.md` file +2. Create the `seasonal-forecast.md` file ```bash -$ nano README.md -$ cat README.md +$ nano seasonal-forecast.md +$ cat seasonal-forecast.md ``` ```output -# Weather +# Seasonal Forecast -A repo for all things weather related! +- Winter is wet +- Summer is hot ``` 3. Add and commit the new file ```bash -$ git add README.md -$ git commit -m "Add in a README file" +$ git add seasonal-forecast.md +$ git commit -m "Add in a seasonal-forecast.md file" ``` ```output -[add-readme aeaf804] Add in a README file - 1 file changed, 3 insertions(+) - create mode 100644 README.md +[add-seasonal-forecast aeaf804] Add in a seasonal-forecast.md file + 1 file changed, 4 insertions(+) + create mode 100644 seasonal-forecast.md ``` 4. Push the changes to GitHub @@ -359,12 +357,12 @@ Writing objects: 100% (3/3), 326 bytes | 163.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (1/1), completed with 1 local object. remote: -remote: Create a pull request for 'add-readme' on GitHub by visiting: -remote: https://github.com/mo-ormerod/weather/pull/new/add-readme +remote: Create a pull request for 'add-seasonal-forecast' on GitHub by visiting: +remote: https://github.com/mo-ormerod/weather/pull/new/add-seasonal-forecast remote: To github.com:mo-ormerod/weather.git - * [new branch] add-readme -> add-readme -branch 'add-readme' set up to track 'origin/add-readme'. + * [new branch] add-seasonal-forecast -> add-seasonal-forecast +branch 'add-seasonal-forecast' set up to track 'origin/add-seasonal-forecast'. ``` 5. Open a PR as shown in this very episode! @@ -402,9 +400,9 @@ $ git pull ```output Updating 49c845c..e4bdab8 Fast-forward - README.md | 3 +++ - 1 file changed, 3 insertions(+) - create mode 100644 README.md + seasonal-forecast.md | 4 +++ + 1 file changed, 4 insertions(+) + create mode 100644 seasonal-forecast.md ``` 8. Tidy up your branches @@ -416,15 +414,15 @@ $ git remote prune origin ```output Pruning origin URL: git@github.com:mo-ormerod/weather.git - * [pruned] origin/add-readme + * [pruned] origin/add-seasonal-forecast ``` ```bash -$ git branch -D add-readme +$ git branch -D add-seasonal-forecast ``` ```output -Deleted branch add-readme (was aeaf804). +Deleted branch add-seasonal-forecast (was aeaf804). ``` ::::::::::::::::::::::::: diff --git a/episodes/14-supplemental-rstudio.md b/episodes/14-supplemental-rstudio.md index 9dc59cdd42..7574865545 100644 --- a/episodes/14-supplemental-rstudio.md +++ b/episodes/14-supplemental-rstudio.md @@ -1,5 +1,5 @@ --- -title: 'Supplemental: Using Git from RStudio' +title: 'Using Git from RStudio' teaching: 10 exercises: 0 --- diff --git a/episodes/Break.md b/episodes/Break.md index 10903a6482..caabcb2254 100644 --- a/episodes/Break.md +++ b/episodes/Break.md @@ -4,4 +4,33 @@ teaching: 0 exercises: 0 --- -This marks the end of the git section. Take a break and remember to fill out your minute card feedback. +This marks the end of the git section. +Take a break and remember to fill out your minute card feedback. + +## Summary + +You've now used Git to create a repository +and made some commits on a feature branch. +Your repository will look something like this: + +```mermaid +--- +config: + gitGraph: + showCommitLabel: false +--- + gitGraph + accDescr {A git graph showing the root-commit on the main branch and a new forecast branch with five commits.} + commit id: 'Initial commit' + branch forecast + commit id: 'Create a md file with the forecast' + commit id: 'Add tomorrows forecast to forecast.md' + commit id: 'Modify the forecast to add a chance of Sun' + commit id: 'Add in the temperature to the forecast and create the weather atlas file' + commit id: 'Ignore png files and the data folder' +``` + +Your repo may have a different number of commits on the forecast branch +depending on which challenge exercises you have completed. +You can find short summaries of all the new commands +you've learnt on the Key Points page. diff --git a/episodes/End.md b/episodes/End.md index 40dfe5fc1e..3969a80963 100644 --- a/episodes/End.md +++ b/episodes/End.md @@ -9,7 +9,7 @@ Please remember to fill out your post-workshop feedback. This feedback is vital for us to keep improving the lesson for other learners. -### Where to next? +## Where to next? The Git working practices lesson teaches you how to work collaboratively with others using git and GitHub. @@ -17,3 +17,43 @@ collaboratively with others using git and GitHub. There are also a number of optional episodes after this page which focus on open science and code which you can read in your own time. + +You can revisit this training anytime. +Useful page links: + +- [Glossary](../learners/reference.md#glossary) +- [Key Points](./key-points.html) +- [Discussion](../learners/discuss.md) page with extra information on some episodes +- [FCM to Git](../learners/fcm-git_cheat_sheet.md) cheat sheet +- [Git cheatsheets](../learners/reference.md) + +## Summary + +You've now created a repository both locally on your computer +and remotely on GitHub. +You've developed changes on a feature branch, +reviewed the changes on GitHub and merged them into `main`. +Your local and remote repositories look something like this: + +```mermaid +--- +config: + gitGraph: + showCommitLabel: false +--- + gitGraph + accDescr {A git graph showing the root-commit on the main branch and a new forecast branch with five commits. The forecast branch has been merged into main using a merge commit via a GitHub Pull Request.} + commit id: 'Initial commit' + branch forecast + commit id: 'Create a md file with the forecast' + commit id: 'Add tomorrows forecast to forecast.md' + commit id: 'Modify the forecast to add a chance of Sun' + commit id: 'Add in the temperature to the forecast and create the weather atlas file' + commit id: 'Ignore png files and the data folder' + checkout main + merge forecast +``` + +A summary page outlining the steps we've taken to create +a new repository locally and connect it to a GitHub remote +can be found in the extra [Quick Start Repository Guide](../learners/repo-quick-start.md). diff --git a/episodes/fig/github_create_pr-dark.png b/episodes/fig/github_create_pr-dark.png index 5730d24041..c120789c6e 100644 Binary files a/episodes/fig/github_create_pr-dark.png and b/episodes/fig/github_create_pr-dark.png differ diff --git a/episodes/fig/github_create_pr.png b/episodes/fig/github_create_pr.png index 89e3862c31..98815b1898 100644 Binary files a/episodes/fig/github_create_pr.png and b/episodes/fig/github_create_pr.png differ diff --git a/episodes/fig/github_create_pr_2-dark.png b/episodes/fig/github_create_pr_2-dark.png index 512bbcc99b..ebf7fc73dc 100644 Binary files a/episodes/fig/github_create_pr_2-dark.png and b/episodes/fig/github_create_pr_2-dark.png differ diff --git a/episodes/fig/github_create_pr_2.png b/episodes/fig/github_create_pr_2.png index be3662fcaa..408358d0e5 100644 Binary files a/episodes/fig/github_create_pr_2.png and b/episodes/fig/github_create_pr_2.png differ diff --git a/episodes/fig/github_pr-dark.png b/episodes/fig/github_pr-dark.png index 39abcaebaa..742c069cb5 100644 Binary files a/episodes/fig/github_pr-dark.png and b/episodes/fig/github_pr-dark.png differ diff --git a/episodes/fig/github_pr.png b/episodes/fig/github_pr.png index 0a95ce8700..57cdce1ee5 100644 Binary files a/episodes/fig/github_pr.png and b/episodes/fig/github_pr.png differ diff --git a/episodes/fig/github_pr_closed-dark.png b/episodes/fig/github_pr_closed-dark.png index 0766d02a7d..d8cd88c675 100644 Binary files a/episodes/fig/github_pr_closed-dark.png and b/episodes/fig/github_pr_closed-dark.png differ diff --git a/episodes/fig/github_pr_closed.png b/episodes/fig/github_pr_closed.png index 4273eb7cda..f10a194d39 100644 Binary files a/episodes/fig/github_pr_closed.png and b/episodes/fig/github_pr_closed.png differ diff --git a/learners/fcm-git_cheat_sheet.md b/learners/fcm-git_cheat_sheet.md index 87a03c6a88..b026619068 100644 --- a/learners/fcm-git_cheat_sheet.md +++ b/learners/fcm-git_cheat_sheet.md @@ -5,7 +5,7 @@ title: FCM vs Git Cheat Sheet ## FCM vs Git If you are familiar with FCM then this cheat sheet is for you! -Adapted from Tomek Trzeciak's comparison page. +Adapted from Tomek Trzeciak's (Met Office) comparison page. ### fcm branch-create BRANCH_NAME (fcm bc) diff --git a/learners/reference.md b/learners/reference.md index 88b7f30695..bb37685cbd 100644 --- a/learners/reference.md +++ b/learners/reference.md @@ -13,6 +13,10 @@ title: 'Git Cheatsheets for Quick Reference' ## Glossary +[branch]{#branch} +: A git branch is a pointer to a commit. Branches are used to develop +changes in parallel, isolated from each other. + [changeset]{#changeset} : A group of changes to one or more files that are or will be added to a single [commit](#commit) in a [version control](#version-control) diff --git a/learners/repo-quick-start.md b/learners/repo-quick-start.md new file mode 100644 index 0000000000..f32030e8b7 --- /dev/null +++ b/learners/repo-quick-start.md @@ -0,0 +1,78 @@ +--- +title: 'Quick Start Repository Guide' +--- + +Creating a new repository is not difficult, but does not happen frequently. +Normally you will be contributing to a repository that has already been +created on GitHub. + +There are two main ways of creating a new repository: +[GitHub-first](./repo-quick-start.md#github-first), +or [local-first](./repo-quick-start.md#local-first). +They are only slightly different, +so which method you use is largely down to preference, +but the focus here is on GitHub-first as overall it is simpler. + +## GitHub First + +This way you will create the GitHub repository first. +Then you will clone the repository to get a local copy. +Cloning and working in this way is covered in the +[Git & GitHub Working Practices](https://www.astropython.com/git-working-practices/) lesson. + +### Create the remote on GitHub + +To create a new repository on GitHub: + +1. Under the "+" menu in the top-right corner of any GitHub page, click [New repository](https://github.com/new) +2. Choose an appropriate owner, name, and visibility + - Private: only you + - Internal (organisations only): read permissions to anyone in the organisation + - Public: read permissions to anyone +3. Tick the box to initialise with a README file (unless [creating a local repository](./repo-quick-start.md#local-first) first) + +### Clone the GitHub remote + +```bash +$ git clone git@github.com:/.git +$ cd +``` + +## Local First + +If you already have files you wish to version control +this approach is best: + +1. Change into the directory containing files you want to version control +2. Initialise the directory as a git repository + +```bash +$ git init +``` + +3. Make an initial commit, where "Repository Name" is replaced with a suitable name for the repository + +```bash +$ echo "# Repository Name" > README.md +$ git add README.md +$ git commit -m "Initial commit" +``` + +4. Check if you are on the `main` branch with `git status` or your terminal prompt + if you have [Git Autocomplete](./setup.md#git-autocomplete) setup. + Rename the default branch from `master` to `main` + (master is considered outdated terminology) if your current branch is `master`. + +```bash +$ git branch -M master main +``` + +5. Create a [new GitHub repository](https://github.com/new) with no files. +5. Set up links to the new GitHub repository + +```bash +git remote add origin git@github.com:/.git +git push +``` + +Adapted from the work of Violet Sherratt (Met Office).