Skip to content

Commit 473107f

Browse files
committed
Make xargs commands less dangerous
1 parent 5d23b75 commit 473107f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,13 @@ git checkout -
225225

226226
## Remove branches that have already been merged with master
227227
```sh
228-
git branch --merged master | grep -v '^\*' | xargs -n 1 git branch -d
228+
git branch --merged master | grep -v '^\*' | xargs -d '\n' -n 1 git branch -d
229229
```
230230

231231

232232
__Alternatives:__
233233
```sh
234-
git branch --merged master | grep -v '^\*\| master' | xargs -n 1 git branch -d # will not delete master if master is not checked out
234+
git branch --merged master | grep -v '^\*\| master' | xargs -d '\n' -n 1 git branch -d # will not delete master if master is not checked out
235235
```
236236

237237
## List all branches and their upstreams, as well as last commit on branch

tips.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"tip": "git checkout -"
3838
}, {
3939
"title": "Remove branches that have already been merged with master",
40-
"tip": "git branch --merged master | grep -v '^\\*' | xargs -n 1 git branch -d",
41-
"alternatives": ["git branch --merged master | grep -v '^\\*\\| master' | xargs -n 1 git branch -d # will not delete master if master is not checked out"]
40+
"tip": "git branch --merged master | grep -v '^\\*' | xargs -d '\\n' -n 1 git branch -d",
41+
"alternatives": ["git branch --merged master | grep -v '^\\*\\| master' | xargs -d '\\n' -n 1 git branch -d # will not delete master if master is not checked out"]
4242
}, {
4343
"title": "List all branches and their upstreams, as well as last commit on branch",
4444
"tip": "git branch -vv"
@@ -440,4 +440,4 @@
440440
}, {
441441
"title": "Preformatted patch file.",
442442
"tip": "git format-patch -M upstream..topic"
443-
}]
443+
}]

0 commit comments

Comments
 (0)