You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61Lines changed: 61 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -327,3 +327,64 @@ To create a new branch, you can use the following command:
327
327
```cmd
328
328
git checkout BRANCH_NAME
329
329
```
330
+
331
+
332
+
333
+
334
+
335
+
# Rename Branches in Git
336
+
337
+
Renaming branches in Git can be an essential part of maintaining a clean and organized repository. Here's a simple guide to help you through the process.
338
+
339
+
#### Why Rename Branches?
340
+
- Clarify branch purpose: A clearer name can better describe the branch's function or contents.
341
+
- Fix typos: Correct any mistakes made when the branch was first created.
342
+
- Follow naming conventions: Ensure consistency and adherence to project guidelines.
343
+
344
+
#### Steps to Rename a Local Branch
345
+
1. Rename the Current Branch
346
+
If you are on the branch you want to rename, follow these steps:
347
+
1. Check the current branch:
348
+
```cmd
349
+
git branch
350
+
```
351
+
The current branch will have an asterisk (*) next to it.
352
+
353
+
2. Rename the branch:
354
+
```cmd
355
+
git branch -m new-branch-name
356
+
```
357
+
Replace `new-branch-name` with your desired branch name.
358
+
359
+
2. Rename a Different Local Branch
360
+
If you are not on the branch you want to rename:
361
+
362
+
1. Rename the branch:
363
+
```cmd
364
+
git branch -m old-branch-name new-branch-name
365
+
```
366
+
Replace `old-branch-name` with the current name and `new-branch-name` with the desired name.
367
+
368
+
#### Delete a branch
369
+
You can delete a branch using the following command:
370
+
371
+
```cmd
372
+
git branch -d <branch-name>
373
+
```
374
+
375
+
Checkout a branch
376
+
You can checkout a branch using the following command:
377
+
378
+
```cmd
379
+
git checkout <branch-name>
380
+
```
381
+
382
+
Checkout a branch means that you are going to work on that branch. You can checkout any branch you want.
383
+
384
+
List all branches
385
+
You can list all branches using the following command:
386
+
387
+
```cmd
388
+
git branch
389
+
```
390
+
List all branches means that you are going to see all the branches in your repository.
0 commit comments