From fbdf4c0f141e66cdbd5c7194a5da97e188493069 Mon Sep 17 00:00:00 2001 From: dhanyapushpadas <90757216+dhanyapushpadas@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:26:48 +0200 Subject: [PATCH 1/4] rename to git switch and main on centralized workflow Using git switch instead of git checkout and use main for default main branch instead of master on centralized workflow --- content/centralized.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/content/centralized.md b/content/centralized.md index 9f4cae1..e96d643 100644 --- a/content/centralized.md +++ b/content/centralized.md @@ -40,7 +40,7 @@ Features: - Typically all developers have both read and write permissions (double-headed arrows). - Suited for cases where **all developers are in the same group or organization or project**. - **Everybody who wants to contribute needs write access**. -- Good idea to write-protect the main branch (typically `master` or `main`). +- Good idea to write-protect the main branch (typically `main`). Real life examples: @@ -184,10 +184,10 @@ Here and in what follows, "c1" is a commit, "b1" etc. are commits on side branch and "m1" is a merge commit. - We clone the entire history, all branches, all commits. In our case, we have one branch (we did not include *all branches* when creating our repository from template) and we have only one commit (*initial commit*). -- `git clone` creates pointers `origin/master` so you can see the branches of the origin. +- `git clone` creates pointers `origin/main` so you can see the branches of the origin. - `origin` refers to where we cloned from. - `origin` is a shortcut for the full URL. -- `origin/master` is a read-only pointer. +- `origin/main` is a read-only pointer. - The branches starting with `origin/` only move during `git pull` or `git fetch` or `git push`. - Only `git pull` or `git fetch` or `git push` require network. - All other operations are local operations. @@ -205,11 +205,11 @@ Try to find out where this repository was cloned from using `git remote -v`. ### Step C. Create a branch `yourname-somefeature` pointing at your commit -Create a branch from the current `master`. Also adapt "yourname-somefeature" to a better name: +Create a branch from the current `main`. Also adapt "yourname-somefeature" to a better name: ```console -$ git branch yourname-somefeature master -$ git checkout yourname-somefeature +$ git branch yourname-somefeature main +$ git switch yourname-somefeature ``` The `yourname-` prefix has no special meaning here (not like `origin/`): it is just part of a @@ -308,7 +308,7 @@ discuss what you see. ### Step H. Submit a pull request -Submit a pull request from your branch towards the `master` branch. +Submit a pull request from your branch towards the `main` branch. Do this through the web interface. Meaning of a pull request: think of it as change proposal. In a popular project, it means that anyone can @@ -389,7 +389,7 @@ At this stage demonstrate how to suggest small changes to pull/merge requests: **Protected branches** -- A good setting for large projects is to make the `master` or `main` branch **protected** and all changes to it have to go +- A good setting for large projects is to make the `main` branch **protected** and all changes to it have to go through code review. - Centralized workflow with protected branches is a good setup for many projects. @@ -407,8 +407,8 @@ exercise repository** but we do this together in the main room so that we can discuss this step and ask questions. ```console -$ git checkout master -$ git pull origin master +$ git switch main +$ git pull origin main ``` ```{figure} img/centralized/06-remote.svg @@ -456,11 +456,11 @@ for more examples. makes a new change (create a new file) but without creating a new branch. - 1. You all create a new file in the master branch, stage and commit your change locally. + 1. You all create a new file in the main branch, stage and commit your change locally. 2. Try to push the change to the upstream repository: ```console - $ git push origin master + $ git push origin main ``` You probably see something like this: @@ -468,7 +468,7 @@ for more examples. $ git push To https://github.com/user/repo.git - ! [rejected] master -> master (non-fast-forward) + ! [rejected] main -> main (non-fast-forward) error: failed to push some refs to 'https://github.com/user/repo.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the @@ -489,7 +489,7 @@ for more examples. ````{discussion} Discussion: How to make changes to remote branches If there is a remote branch `somefeature`, we can create a local branch and start tracking `origin/somefeature` like this: ```console - $ git checkout somefeature + $ git switch somefeature ``` Once we track a remote branch, we can pull from it and push to it: From 9e1888b463993e33ebe1718112b417a62f3c1a65 Mon Sep 17 00:00:00 2001 From: dhanyapushpadas <90757216+dhanyapushpadas@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:45:15 +0200 Subject: [PATCH 2/4] checkout to switch and master to main on distributed workflow use git switch instead of git checkout and use main for default branch instead of master but figures are not changed on distributed workflow --- content/distributed.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/content/distributed.md b/content/distributed.md index 69e5e07..ccdcfa4 100644 --- a/content/distributed.md +++ b/content/distributed.md @@ -236,7 +236,7 @@ its content. For example: ```console $ git branch myname-feature # describes both who it belongs to and the purpose -$ git checkout myname-feature +$ git switch myname-feature ``` **On the new branch create a new file** which will hold your recipe, @@ -321,7 +321,7 @@ local ### Step E: Open a pull request -Then file a pull request from the branch on your fork towards the master branch on the central repository. +Then file a pull request from the branch on your fork towards the main branch on the central repository. ````{admonition} Pictorial representation for steps D and E --- @@ -416,9 +416,9 @@ instead of aliases like `origin` or `upstream`. Here we pull from the central repo and push to our fork: ```console -$ git checkout master -$ git pull master -$ git push master +$ git switch main +$ git pull main +$ git push main ``` Here is a pictorial representation of this part: @@ -456,8 +456,8 @@ local ``` ```console -$ git checkout master -$ git merge central/master +$ git switch main +$ git merge central/main ``` ```{figure} img/forking/github-remote-03.svg @@ -476,7 +476,7 @@ local ``` ```console -$ git push origin master +$ git push origin main ``` ```{figure} img/forking/github-remote-03.svg From f3a4f4523a0f8e5dae062e38020cab88cdd450bb Mon Sep 17 00:00:00 2001 From: dhanyapushpadas <90757216+dhanyapushpadas@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:51:02 +0200 Subject: [PATCH 3/4] master to main for default branch and use git switch instead of git checkout on reference page --- content/reference.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/reference.md b/content/reference.md index 2e38a3d..2fef4ed 100644 --- a/content/reference.md +++ b/content/reference.md @@ -19,7 +19,7 @@ the basics. * **pull**: Fetch (above) and then merge * **origin**: Default name for a remote repository. * **origin/NAME**: A branch name which represents a remote branch. -* **master**: Default name for main branch. +* **main**: Default name for main branch. * **merge**: Combine the changes on two branches. * **conflict**: When a merge has changes that affect the same lines, git can not automatically figure out what to do. It presents the @@ -55,7 +55,7 @@ Status: General work: -* `git checkout `: Make a branch active. +* `git switch `: Make a branch active. * `git push [] [:]`: Send commits and update the branch on the remote. * `git pull [] []`: Fetch and then merge From 1d91dd424ed5e7a627e6b57da9293b15d8851762 Mon Sep 17 00:00:00 2001 From: dhanyapushpadas <90757216+dhanyapushpadas@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:53:48 +0200 Subject: [PATCH 4/4] main as default branch on concept page --- content/remotes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/remotes.md b/content/remotes.md index d532fea..344c36a 100644 --- a/content/remotes.md +++ b/content/remotes.md @@ -23,7 +23,7 @@ - **repository**: The project, contains all data and history (commits, branches, tags). - **commit**: Snapshot of the project, gets a unique identifier (e.g. `c7f0e8bfc718be04525847fc7ac237f470add76e`). -- **branch**: Independent development line. The main development line is often called `main` or `master`. +- **branch**: Independent development line. The main development line is often called `main`. - **tag**: A pointer to one commit, to be able to refer to it later. Like a [commemorative plaque](https://en.wikipedia.org/wiki/Commemorative_plaque) that you attach to a particular commit (e.g. `phd-printed` or `paper-submitted`). - **cloning**: Copying the whole repository to your laptop - the first time. It is not necessary to download each file one by one.