1.3) GitHub Branches hinzugefügt
34
1.3%29-GitHub-Branches.md
Normal file
34
1.3%29-GitHub-Branches.md
Normal file
@@ -0,0 +1,34 @@
|
||||
## 1.3) GitHub Branches
|
||||
|
||||
A branch in Git and GitHub is a lightweight pointer to one of your commits. It allows you to work on different versions of a project at the same time, without affecting the main project or other branches.
|
||||
Branching enables collaborative workflows, feature development, bug fixing, and experimentations, all in isolation from each other.
|
||||
|
||||
Here's a breakdown of what GitHub branches are and how they work:
|
||||
|
||||
The Default Branch: **main**
|
||||
```When you create a new GitHub repository, it automatically has a branch called main (or previously master). This is often referred to as the default branch.
|
||||
It typically represents the stable version of the project, and most code changes are eventually merged into this branch.```
|
||||
|
||||
**Creating New Branches**
|
||||
```
|
||||
Branches allow you to isolate your work. For example, you might create a new branch to develop a feature, fix a bug, or test out an idea. You can create a branch for each of these tasks.
|
||||
|
||||
In GitHub Desktop: You can easily create a new branch by selecting Branch > New Branch from the top menu.
|
||||
In Git CLI: Run git branch <branch-name> to create a new branch.
|
||||
```
|
||||
|
||||
**Working on a Branch**
|
||||
```
|
||||
Once you switch to a branch, any changes you make (like adding files, editing code, or fixing bugs) will only apply to that branch. The main branch remains unaffected until you explicitly merge the branch back into it.
|
||||
Your changes stay isolated from the default main branch until you are ready to combine them.```
|
||||
|
||||
https://i.imgur.com/TUgsQZD.png
|
||||
|
||||
**Merging Branches**
|
||||
```
|
||||
When your work on a branch is complete, you can merge the branch back into the main branch (or any other branch). Merging is the process of combining the changes from one branch into another.
|
||||
|
||||
On GitHub: You typically create a Pull Request (PR) to merge a branch into main. This allows team members to review the changes before merging them.
|
||||
|
||||
Once merged, the changes from your branch are added to the main branch.
|
||||
```
|
||||
Reference in New Issue
Block a user