Skip to content

Commit 6c3defa

Browse files
add branches in git
1 parent e815cda commit 6c3defa

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,52 @@ Project Structure: Sometimes, you need to maintain a specific directory structur
278278
- **Consistency** : Use .gitkeep consistently across your projects to avoid confusion.
279279
- **Documentation** : Add a note in your project’s documentation explaining why and where you use .gitkeep.
280280
- **Cleanliness** : Periodically check if the directories still need to be empty or if files have been added, making .gitkeep unnecessary.
281+
282+
283+
284+
# Branches in git
285+
Git branches are a core feature in version control, allowing developers to work on different parts of a project simultaneously without interfering with the main codebase.
286+
287+
#### What is a Git Branch?
288+
A Git branch is a separate line of development. Think of it as a new copy of your project where you can make changes without affecting the main codebase.
289+
290+
#### Why Use Branches?
291+
- **Parallel Development**v : Work on multiple features or bug fixes at the same time.
292+
- **Isolation** : Keep changes separate until they’re ready to be merged.
293+
- **Collaboration** : Multiple developers can work on different branches without conflicts.
294+
295+
296+
![git branches](https://app.eraser.io/workspace/naKDsmwtCmZiDgeMuuFA/preview?elements=qTNZMYYuBsW8HPCASTIR4Q&type=embed)
297+
298+
#### **Creating a new branch**
299+
To create a new branch, you can use the following command:
300+
301+
302+
> `git branch` - This command lists all the branches in the current repository.
303+
304+
```cmd
305+
git branch
306+
```
307+
308+
> `git branch BRANCH_NAME` - This command creates a new branch called `BRANCH_NAME`.
309+
310+
```cmd
311+
git branch BRANCH_NAME
312+
```
313+
> `git switch BRANCH_NAME` - This command switches to the `BRANCH_NAME` branch.
314+
315+
```cmd
316+
git switch BRANCH_NAME
317+
```
318+
319+
> `git switch -c another_branch` - This command creates a new branch called dark-mode. the `-c` flag is used to create a new branch.
320+
321+
```cmd
322+
git switch -c another_branch
323+
```
324+
325+
> `git checkout BRANCH_NAME` - This command switches to the `BRANCH_NAME` branch.
326+
327+
```cmd
328+
git checkout BRANCH_NAME
329+
```

0 commit comments

Comments
 (0)