-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDelete_branches
58 lines (38 loc) · 1.38 KB
/
Delete_branches
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
To delete feature branches:
- requires to be switched to a different branch
git branch -d feature_branch_1 # with -d informes for deleting feature_branch_1
# does not delete feature_branch_1
git branch -D feature_branch_1 # with -D deletes feature_branch_1
To delete remote branches:
git push origin :feature_branch_1
git push --delete origin feature_branch_1
git push -d origin feature_branch_1
Example:
git checkout -b delete_test # creates & switches to delete_test branch
git branch # checks in which branch you're currently in
*delete_test
master
git push -u origin delete_test # track the new feature branch on remote
git branch -r # shows all branches from remote
origin/master
origin/delete_test
git branch # checks in which branch you're currently in
*delete_test
master
git branch -d delete_test
!!! Error: Cannot delete branch 'delete_test' checked out at ...
git commit -am "Change file for testing" # change & commit file
git merge master
git branch --merged # check all merged branches
* master
git checkout master
git branch -d delete_test
!!! Error: The branch delete_test is not fully merged
If you are sure you want to delete it, run 'git branch -D delete_test'
git branch -D delete_test
git branch -r # remote feature still appears
origin/delete_test
orogin/master
git push -d origin delete_test
git branch -r
origin/master