OSDN Git Service

Regular updates
[twpd/master.git] / git-branch.md
index 1a98a48..0057ba9 100644 (file)
@@ -2,7 +2,7 @@
 title: Git branches
 category: Git
 layout: 2017/sheet
-updated: 2017-09-20
+updated: 2020-02-13
 ---
 
 ## Working with branches
@@ -64,12 +64,17 @@ Deletes the branch only if the changes have been pushed and merged with remote.
 git branch -D $branchname
 ```
 
-Delete a branch irrespective of its merged status.
+```bash
+git branch -d $branchname
+```
+
+> Note: You can also use the -D flag which is synonymous with --delete --force instead of -d. This will delete the branch regardless of its merge status.
+> Delete a branch irrespective of its merged status.
 
 ### Delete remote branch
 
 ```bash
-git push origin :$branchname
+git push origin --delete :$branchname
 ```
 
 Works for tags, too!
@@ -90,6 +95,9 @@ git reset --hard
 ```bash
 git reset --hard $commit_id
 
-# Now push to your branch
+# Now push safely to your branch
+git push --force-with-lease
+
+# Or push brutally to your branch
 git push --force
 ```