Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update branches-in-git.md #3034

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ Types of change:
### Fixed
- [MongoDb - Aggregation With $last - Replace $first operator with $last](https://github.com/enkidevs/curriculum/pull/3038)

## January 31st 2022

### Added
- [Git - Branches In Git - Add info on git switch, convert RQ to fill-in-the-gap](https://github.com/enkidevs/curriculum/pull/3034)

## January 25th 2022

### Fixed
Expand Down
26 changes: 20 additions & 6 deletions git/essentials/git-fundamentals/branches-in-git.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ links:
- >-
[Git Branching Official
Documentation](https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell){website}
- >-
[Git Switch Official
Documentation](https://git-scm.com/docs/git-switch){website}
practiceQuestion:
formats:
- fill-in-the-gap
Expand All @@ -14,7 +17,6 @@ practiceQuestion:
revisionQuestion:
formats:
- fill-in-the-gap
- type-in-the-gap
context: standalone
---

Expand Down Expand Up @@ -79,6 +81,10 @@ Thinking of a branch as a pointer to a specific state of the repository, we can
git checkout my-branch
```

Or we can also use `git switch`[5]:
```bash
git switch my-branch
```

---

Expand All @@ -103,15 +109,14 @@ git ??? ??? my-branch

## Revision

The command used in **Git** to switch between branches:
The command/s used in **Git** to switch between branches:

```bash
???
```

- `git checkout`
- `git branch`
- `git checkout or git switch`
- `git branch or git checkout`
- `git branch -m`
- `git checkout switch branch -m`


---
Expand All @@ -133,3 +138,12 @@ Using the `git checkout` command together with the `-b` flag, you can simultaneo
```bash
git checkout -b my-branch
```

[5:switch]
Using the `git switch -c my-branch` command, you can simultaneously create a new branch and switch to it:

> The `-c` flag means to create a new branch if the specified `my-branch` does not exist. Without `-c`, you can only switch to an existing one.

```bash
git switch -c my-branch
```