Skip to content

Commit 31a72d2

Browse files
committed
added: New post - Git Branch and Merge PRs
1 parent d7ab0cd commit 31a72d2

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

_posts/2023-02-10-git-branching.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Git Branch & Merge PR's
3+
author: alkaison
4+
date: 2023-02-10 16:00:00 +0530
5+
categories: [Blogging, Git & GitHub]
6+
tags: [git, github, git branch, git terminal, version control]
7+
---
8+
9+
- In Git, a branch is a new/separate version of the main repository.
10+
11+
- Branches allow you to work on different parts of a project without impacting the main branch. When the work is complete, a branch can be merged with the main project.
12+
13+
- We can even switch between branches and work on different projects without them interfering with each other.
14+
15+
### New Git Branch
16+
17+
```terminal
18+
git branch <name of branch>
19+
```
20+
21+
### Check All Branches
22+
23+
```terminal
24+
git branch
25+
```
26+
27+
### Switching to other branches
28+
29+
```terminal
30+
git checkout <branch name>
31+
```
32+
33+
### Making a new branch and directly switching to it
34+
35+
```terminal
36+
git checkout -b <branch name>
37+
```
38+
39+
### Deleting a branch
40+
41+
```terminal
42+
git branch -d <branch name>
43+
```
44+
45+
### Merging two branches
46+
47+
- It’s preferred to change/switch to master branch before any branch needs to be merged with it.
48+
49+
```terminal
50+
git merge <branch name>
51+
```
52+
53+
- This will merge the specified branch with our master branch.

0 commit comments

Comments
 (0)