From 7d5cdc7d5907f2a02a4b1b750999bbf295eb98cd Mon Sep 17 00:00:00 2001 From: Mahesh Binzer-Panchal Date: Tue, 19 Mar 2024 12:53:09 +0100 Subject: [PATCH 01/18] Create git_intro.qmd --- git/git_intro.qmd | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 git/git_intro.qmd diff --git a/git/git_intro.qmd b/git/git_intro.qmd new file mode 100644 index 0000000..33b42a3 --- /dev/null +++ b/git/git_intro.qmd @@ -0,0 +1,16 @@ +# Introduction to Git + +## What is git + +## What should git be used for + +## Git Repositories + +## Git branches + +## File staging and git commit + +## Git push/pull + +## Git merge and git rebase + From 98551a3465a64836d00f37e08b7d0d9e79e26dbd Mon Sep 17 00:00:00 2001 From: Guilherme Borges Dias Date: Mon, 25 Mar 2024 13:50:56 +0100 Subject: [PATCH 02/18] Update git_intro.qmd --- git/git_intro.qmd | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 33b42a3..5b6c048 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -6,6 +6,19 @@ ## Git Repositories +- A git repository (repo) is any folder structure that is version-controlled by git. +- A git repo can be initialized from a local folder, or cloned from a remote repo. + - To initialize a repo from a local folder: +```bash +cd myfolder +git init +``` + - To clone a git repo from a remote source: +```bash +git clone https://github.com/user/repo +``` +- Regardless of how you obtain it, your local copy of the git repo will contain a `.git` folder. That is where the change history of your project is stored and maintained by git. + ## Git branches ## File staging and git commit From 795ec72b5690e52cf78f79550aa6cc0d5a915a49 Mon Sep 17 00:00:00 2001 From: Estelle PW Date: Mon, 25 Mar 2024 14:30:01 +0100 Subject: [PATCH 03/18] Update git_intro.qmd - what is Git A few lines about what Git is and what should it be used for --- git/git_intro.qmd | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 33b42a3..2d0f60a 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -1,8 +1,16 @@ # Introduction to Git -## What is git +## What is Git -## What should git be used for +Git is nowadays the most widely used distributed version controle system, especially in software developement. By opposition to centralized version control systems, with Git, the code source, including its full history, is mirrored on every developer's computer. + +Git is the most popular tool, even though it might not be the most user-friendly one. It has a lot of options/commands and a specific jargon. Fortunately there are many "Git cheat sheets" (such as https://education.github.com/git-cheat-sheet-education.pdf). + +## What should Git be used for + +In software development, Git is mostly used for version controle of code. In our bioinformatics projects, we can also track our report files, environment files, and other small files. + +Git should NOT be used for storing data, particularly large data. Sensitive data (passwords, usernames, API keys...) should not be put in a Git repository, because they can be then exposed to the world. One can go back into the file history and extract data, so you should remove any problematic files from the Git history as well. ## Git Repositories From c81fbe7319d8a2d165a4c46ca28bc4253d05df7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Redondo?= <105673050+RedondoMA@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:50:26 +0100 Subject: [PATCH 04/18] Update branches at git_intro_.qmd --- git/git_intro.qmd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 33b42a3..bdfd64d 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -7,6 +7,13 @@ ## Git Repositories ## Git branches +Once you have cloned a specific git repository locally on your computer, you can navigate and/or create new branches on it using git CLI. Here some examples: +- To create a branch and switch to it type `git checkout -b branch_name` +- To push the newly created branch to the remote repository type `git push -u origin branch_name` +- To display all branches on the local and remote repository type `git branch -a` +- To switch to some of the displayed branches type `git ckeckout name_of_branch`. **Once a change is commited from that branch, pushing the committed change will be pushed into that specific branch.** +- To delete a branch type `git branch -d name_of_branch_to_delete` + ## File staging and git commit From 0c0b2cd846c1e2a136d6cc7db8b84ca14472d103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Redondo?= <105673050+RedondoMA@users.noreply.github.com> Date: Tue, 26 Mar 2024 15:10:52 +0100 Subject: [PATCH 05/18] Update git/git_intro.qmd Co-authored-by: Mahesh Binzer-Panchal --- git/git_intro.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index bdfd64d..618db95 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -11,7 +11,7 @@ Once you have cloned a specific git repository locally on your computer, you can - To create a branch and switch to it type `git checkout -b branch_name` - To push the newly created branch to the remote repository type `git push -u origin branch_name` - To display all branches on the local and remote repository type `git branch -a` -- To switch to some of the displayed branches type `git ckeckout name_of_branch`. **Once a change is commited from that branch, pushing the committed change will be pushed into that specific branch.** +- To switch to one of the displayed branches type `git ckeckout name_of_branch`. **Once a change is committed to that branch, pushing the committed change will be pushed to that specific branch on the remote repository.** - To delete a branch type `git branch -d name_of_branch_to_delete` From 8fe7e83dc5b13fb529c4a9d69e46d7f386e5c17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Redondo?= <105673050+RedondoMA@users.noreply.github.com> Date: Wed, 27 Mar 2024 09:38:21 +0100 Subject: [PATCH 06/18] Update git/git_intro.qmd Co-authored-by: Mahesh Binzer-Panchal --- git/git_intro.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 618db95..392d211 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -11,7 +11,7 @@ Once you have cloned a specific git repository locally on your computer, you can - To create a branch and switch to it type `git checkout -b branch_name` - To push the newly created branch to the remote repository type `git push -u origin branch_name` - To display all branches on the local and remote repository type `git branch -a` -- To switch to one of the displayed branches type `git ckeckout name_of_branch`. **Once a change is committed to that branch, pushing the committed change will be pushed to that specific branch on the remote repository.** +- To switch to one of the displayed branches type `git checkout name_of_branch`. **Once a change is committed to that branch, pushing the committed change will be pushed to that specific branch on the remote repository.** - To delete a branch type `git branch -d name_of_branch_to_delete` From 471e98cff33d641cecd4c1a5755129b66c465a34 Mon Sep 17 00:00:00 2001 From: Martin Pippel Date: Wed, 27 Mar 2024 13:50:50 +0100 Subject: [PATCH 07/18] Update git_intro.qmd - File staging and git commit --- git/git_intro.qmd | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 5b6c048..3f8543d 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -23,6 +23,29 @@ git clone https://github.com/user/repo ## File staging and git commit +Staging in Git involves adding new, modified, or deleted files to a staging area before committing them. This allows for flexibility in choosing the files to commit. + +1. Check status via `git status` You'll see what branch you are on (which for new repos will be master) and status of files (untracked, modified, or deleted). +2. Stage Files to Prepare for Commit + - Stage all files: `git add .` + - Stage a file: `git add example.html` + - Stage a folder: `git add myfolder` +3. Check status again: `git status` You should see there are changes ready to be committed. +4. Unstage a File + - If you accidental stage something, use the following command to unstage it: `git reset HEAD example.html` +5. Deleting Files + - If you delete files they will appear in git status as deleted, and you must use git add to stage them. Another way to do this is using git rm command, which both deletes a file and stages it all with one command: + - `git rm example.html` to remove a file (and stage it) + - `git rm -r myfolder` to remove a folder (and stage it) +6. Commit Files + - `git commit -m "Message that describes what this change does"` +7. Check status again: `git status` If all changes have been committed, and there are no untracked files, it should say: nothing to commit, working tree clean. +8. View a List of Commits + - When viewing a list of commits, there are various commands depending on how much info you want to see. + - To see a simplified list of commits, run this command: `git log --oneline` + - To see a list of commits with more detail (such who made the commit and when), run this command: `git log` NOTE: If the list is long, use the Down/Up Arrow keys to scroll and hit Q to quit. + - To see a list of commits with even more detail (including which files changed), run this command: `git log --stat` + ## Git push/pull ## Git merge and git rebase From cdf216a3a42088c04262876b63fcb980db9fa21f Mon Sep 17 00:00:00 2001 From: Martin Pippel Date: Thu, 28 Mar 2024 12:43:27 +0100 Subject: [PATCH 08/18] Update git_intro.qmd - File staging and git commit remove phase about default branch name --- git/git_intro.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 3f8543d..1c38b34 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -25,7 +25,7 @@ git clone https://github.com/user/repo Staging in Git involves adding new, modified, or deleted files to a staging area before committing them. This allows for flexibility in choosing the files to commit. -1. Check status via `git status` You'll see what branch you are on (which for new repos will be master) and status of files (untracked, modified, or deleted). +1. Check status via `git status` You'll see what branch you are on and status of files (untracked, modified, or deleted). 2. Stage Files to Prepare for Commit - Stage all files: `git add .` - Stage a file: `git add example.html` From 8cfd75e795fbf07d99091b77172819a01e4cd333 Mon Sep 17 00:00:00 2001 From: Martin Pippel Date: Thu, 28 Mar 2024 15:38:06 +0100 Subject: [PATCH 09/18] Update git_intro.qmd --- git/git_intro.qmd | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 1c38b34..cb4ed11 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -45,6 +45,19 @@ Staging in Git involves adding new, modified, or deleted files to a staging area - To see a simplified list of commits, run this command: `git log --oneline` - To see a list of commits with more detail (such who made the commit and when), run this command: `git log` NOTE: If the list is long, use the Down/Up Arrow keys to scroll and hit Q to quit. - To see a list of commits with even more detail (including which files changed), run this command: `git log --stat` +9a). Fixing Your Last Commit Message + - `git commit --amend -m "Put your corrected message here"`: to correct a mistake in your last commit message +9b). Changing committed files + - The `--no-edit` flag will allow you to make the amendment to your commit without changing its commit message. Example: + ```bash + # Edit hello.py and main.py + git add hello.py + git commit + # Realize you forgot to add the changes from main.py + git add main.py + git commit --amend --no-edit + ``` + The resulting commit will replace the incomplete one, and it will look like we committed the changes to hello.py and main.py in a single snapshot. ## Git push/pull From a15dd2efc89ab2bb1bfa0234579a67fe53464dfa Mon Sep 17 00:00:00 2001 From: Estelle PW Date: Tue, 2 Apr 2024 10:59:46 +0200 Subject: [PATCH 10/18] Update git/git_intro.qmd Co-authored-by: Mahesh Binzer-Panchal --- git/git_intro.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 2d0f60a..18919bd 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -2,7 +2,7 @@ ## What is Git -Git is nowadays the most widely used distributed version controle system, especially in software developement. By opposition to centralized version control systems, with Git, the code source, including its full history, is mirrored on every developer's computer. +Git is nowadays the most widely used distributed version control system, especially in software development. By opposition to centralized version control systems, with Git, the code source, including its full history, is mirrored on every developer's computer. Git is the most popular tool, even though it might not be the most user-friendly one. It has a lot of options/commands and a specific jargon. Fortunately there are many "Git cheat sheets" (such as https://education.github.com/git-cheat-sheet-education.pdf). From 8a7d31bdafe8c9246e39c6e80123a94d983e800b Mon Sep 17 00:00:00 2001 From: Tomas Larsson Date: Tue, 2 Apr 2024 11:40:07 +0200 Subject: [PATCH 11/18] Update git_intro.qmd Added git push/pull and merge/rebase sections --- git/git_intro.qmd | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index cb4ed11..402dcaf 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -60,6 +60,26 @@ Staging in Git involves adding new, modified, or deleted files to a staging area The resulting commit will replace the incomplete one, and it will look like we committed the changes to hello.py and main.py in a single snapshot. ## Git push/pull +You can use `git push` to sync a remote repository with the changes you've done locally. +The most basic example would be that you've first cloned a repository with `git clone` then made some changes in that local copy and want to update the original remote repository. +Similarly, if for example, someone else made changes to the remote and you want to incorporate those changes into your local copy you will run `git pull` to make sure you are up to date with the changes in the remote repository before working on your local copy. ## Git merge and git rebase +Git merge and git rebase can be said to be used to solve similar things. +When working on a feature in a separate branch while someone else updates the main branch you often want to incorporate the new changes from the main branch into your feature branch. +This could be done with merge like this: + +`git checkout my_new_feature` +`git merge main` + +This will create what is called a "merge commit" and put the changes from main into your feature branch. + +The alternative way would be to use rebase: + +`git checkout my_new_feature` +`git rebase main` + +This will sort of re-write the project history by moving the feature branch to the "tip" of the main and create new commits in the original branch. + + From 7cccdf018370c2ec1033004dede831ff2cea050a Mon Sep 17 00:00:00 2001 From: Martin Pippel Date: Mon, 15 Apr 2024 15:39:23 +0200 Subject: [PATCH 12/18] Update git/git_intro.qmd - little typo --- git/git_intro.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 18919bd..2f0bc54 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -8,7 +8,7 @@ Git is the most popular tool, even though it might not be the most user-friendly ## What should Git be used for -In software development, Git is mostly used for version controle of code. In our bioinformatics projects, we can also track our report files, environment files, and other small files. +In software development, Git is mostly used for version control of code. In our bioinformatics projects, we can also track our report files, environment files, and other small files. Git should NOT be used for storing data, particularly large data. Sensitive data (passwords, usernames, API keys...) should not be put in a Git repository, because they can be then exposed to the world. One can go back into the file history and extract data, so you should remove any problematic files from the Git history as well. From ccae2b98cb0cbacc7b0efb1aa7134c4d4a8e5b33 Mon Sep 17 00:00:00 2001 From: Tomas Larsson Date: Mon, 15 Apr 2024 15:48:11 +0200 Subject: [PATCH 13/18] Update git_intro.qmd --- git/git_intro.qmd | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 402dcaf..c626469 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -67,9 +67,12 @@ Similarly, if for example, someone else made changes to the remote and you want ## Git merge and git rebase Git merge and git rebase can be said to be used to solve similar things. When working on a feature in a separate branch while someone else updates the main branch you often want to incorporate the new changes from the main branch into your feature branch. -This could be done with merge like this: -`git checkout my_new_feature` +First you would probably like to use `git pull` as described above to make sure your local copy is up-to-date with changes made by others. + +Then it could be done with merge like this: + +`git checkout my_new_feature` followed by adding your new code/feature and then merge it: `git merge main` This will create what is called a "merge commit" and put the changes from main into your feature branch. From 5043edb1c9619710e84861b3f0cff040c422e383 Mon Sep 17 00:00:00 2001 From: Tomas Larsson Date: Wed, 17 Apr 2024 14:00:48 +0200 Subject: [PATCH 14/18] Update git_intro.qmd --- git/git_intro.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index c626469..3239955 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -70,7 +70,7 @@ When working on a feature in a separate branch while someone else updates the ma First you would probably like to use `git pull` as described above to make sure your local copy is up-to-date with changes made by others. -Then it could be done with merge like this: +Then it could be done with merge like this: `git checkout my_new_feature` followed by adding your new code/feature and then merge it: `git merge main` From 1476809b4b163358297fa9fa9a70f0f98d0247ed Mon Sep 17 00:00:00 2001 From: Estelle PW Date: Wed, 17 Apr 2024 14:12:50 +0200 Subject: [PATCH 15/18] Update git/git_intro.qmd Co-authored-by: Mahesh Binzer-Panchal --- git/git_intro.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 2f0bc54..9957553 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -10,7 +10,7 @@ Git is the most popular tool, even though it might not be the most user-friendly In software development, Git is mostly used for version control of code. In our bioinformatics projects, we can also track our report files, environment files, and other small files. -Git should NOT be used for storing data, particularly large data. Sensitive data (passwords, usernames, API keys...) should not be put in a Git repository, because they can be then exposed to the world. One can go back into the file history and extract data, so you should remove any problematic files from the Git history as well. +Git should NOT be used for storing data, particularly large data. Sensitive data (passwords, usernames, API keys...) should not be put in a Git repository, because they can be then exposed to the world. If one commits sensitive data by mistake, one can go back into the git history and remove it, but it is not a simple task. ## Git Repositories From 9d2b310d57d4c9118532f38cf589730dc82cc53b Mon Sep 17 00:00:00 2001 From: Estelle PW Date: Wed, 17 Apr 2024 14:13:02 +0200 Subject: [PATCH 16/18] Update git/git_intro.qmd Co-authored-by: Mahesh Binzer-Panchal --- git/git_intro.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index 9957553..c12a48c 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -4,7 +4,7 @@ Git is nowadays the most widely used distributed version control system, especially in software development. By opposition to centralized version control systems, with Git, the code source, including its full history, is mirrored on every developer's computer. -Git is the most popular tool, even though it might not be the most user-friendly one. It has a lot of options/commands and a specific jargon. Fortunately there are many "Git cheat sheets" (such as https://education.github.com/git-cheat-sheet-education.pdf). +Git is the most popular tool, even though it might not be the most user-friendly one. It has a lot of options/commands and specific jargon. Fortunately there are many "Git cheat sheets" (such as https://education.github.com/git-cheat-sheet-education.pdf). ## What should Git be used for From 0eccd0d1d722c272fb6de78987b244df7cc38ef7 Mon Sep 17 00:00:00 2001 From: Mahesh Binzer-Panchal Date: Wed, 17 Apr 2024 13:53:13 +0000 Subject: [PATCH 17/18] Add Git intro to project yml --- _quarto.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/_quarto.yml b/_quarto.yml index df73fb0..d6351a6 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -12,6 +12,9 @@ book: chapters: - index.qmd - intro.qmd + - part: "Git" + chapters: + - git/git_intro.qmd - part: "Github" chapters: - github/gh-collaboration.qmd @@ -23,8 +26,6 @@ bibliography: references.bib format: html: theme: minty - # pdf: - # documentclass: scrreprt From ac74291c757a1363a9a7da8cbf377052634f9a49 Mon Sep 17 00:00:00 2001 From: Mahesh Binzer-Panchal Date: Wed, 17 Apr 2024 13:53:30 +0000 Subject: [PATCH 18/18] Fix syntax --- git/git_intro.qmd | 49 +++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/git/git_intro.qmd b/git/git_intro.qmd index d447500..3a15487 100644 --- a/git/git_intro.qmd +++ b/git/git_intro.qmd @@ -17,18 +17,19 @@ Git should NOT be used for storing data, particularly large data. Sensitive data - A git repository (repo) is any folder structure that is version-controlled by git. - A git repo can be initialized from a local folder, or cloned from a remote repo. - To initialize a repo from a local folder: -```bash -cd myfolder -git init -``` + ```bash + cd myfolder + git init + ``` - To clone a git repo from a remote source: -```bash -git clone https://github.com/user/repo -``` + ```bash + git clone https://github.com/user/repo + ``` - Regardless of how you obtain it, your local copy of the git repo will contain a `.git` folder. That is where the change history of your project is stored and maintained by git. ## Git branches Once you have cloned a specific git repository locally on your computer, you can navigate and/or create new branches on it using git CLI. Here some examples: + - To create a branch and switch to it type `git checkout -b branch_name` - To push the newly created branch to the remote repository type `git push -u origin branch_name` - To display all branches on the local and remote repository type `git branch -a` @@ -60,26 +61,28 @@ Staging in Git involves adding new, modified, or deleted files to a staging area - To see a simplified list of commits, run this command: `git log --oneline` - To see a list of commits with more detail (such who made the commit and when), run this command: `git log` NOTE: If the list is long, use the Down/Up Arrow keys to scroll and hit Q to quit. - To see a list of commits with even more detail (including which files changed), run this command: `git log --stat` -9a). Fixing Your Last Commit Message +9. Fixing Your Last Commit Message - `git commit --amend -m "Put your corrected message here"`: to correct a mistake in your last commit message -9b). Changing committed files +10. Changing committed files - The `--no-edit` flag will allow you to make the amendment to your commit without changing its commit message. Example: ```bash - # Edit hello.py and main.py - git add hello.py - git commit - # Realize you forgot to add the changes from main.py - git add main.py - git commit --amend --no-edit + # Edit hello.py and main.py + git add hello.py + git commit + # Realize you forgot to add the changes from main.py + git add main.py + git commit --amend --no-edit ``` The resulting commit will replace the incomplete one, and it will look like we committed the changes to hello.py and main.py in a single snapshot. ## Git push/pull + You can use `git push` to sync a remote repository with the changes you've done locally. The most basic example would be that you've first cloned a repository with `git clone` then made some changes in that local copy and want to update the original remote repository. Similarly, if for example, someone else made changes to the remote and you want to incorporate those changes into your local copy you will run `git pull` to make sure you are up to date with the changes in the remote repository before working on your local copy. ## Git merge and git rebase + Git merge and git rebase can be said to be used to solve similar things. When working on a feature in a separate branch while someone else updates the main branch you often want to incorporate the new changes from the main branch into your feature branch. @@ -87,15 +90,23 @@ First you would probably like to use `git pull` as described above to make sure Then it could be done with merge like this: -`git checkout my_new_feature` followed by adding your new code/feature and then merge it: -`git merge main` +```bash +git checkout my_new_feature +``` + +followed by adding your new code/feature and then merge it: +```bash +git merge main +``` This will create what is called a "merge commit" and put the changes from main into your feature branch. The alternative way would be to use rebase: -`git checkout my_new_feature` -`git rebase main` +```bash +git checkout my_new_feature +git rebase main +``` This will sort of re-write the project history by moving the feature branch to the "tip" of the main and create new commits in the original branch.