Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make xargs commands less dangerous #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ git checkout -

## Remove branches that have already been merged with master
```sh
git branch --merged master | grep -v '^\*' | xargs -n 1 git branch -d
git branch --merged master | grep -v '^\*' | sed 's/^ \+//' | xargs -d '\n' -n 1 git branch -d
```


__Alternatives:__
```sh
git branch --merged master | grep -v '^\*\| master' | xargs -n 1 git branch -d # will not delete master if master is not checked out
git branch --merged master | grep -v '^\*\| master' | sed 's/^ \+//' | xargs -d '\n' -n 1 git branch -d # will not delete master if master is not checked out
```

## List all branches and their upstreams, as well as last commit on branch
Expand Down
6 changes: 3 additions & 3 deletions tips.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"tip": "git checkout -"
}, {
"title": "Remove branches that have already been merged with master",
"tip": "git branch --merged master | grep -v '^\\*' | xargs -n 1 git branch -d",
"alternatives": ["git branch --merged master | grep -v '^\\*\\| master' | xargs -n 1 git branch -d # will not delete master if master is not checked out"]
"tip": "git branch --merged master | grep -v '^\\*' | sed 's/^ \\+//' | xargs -d '\\n' -n 1 git branch -d",
"alternatives": ["git branch --merged master | grep -v '^\\*\\| master' | sed 's/^ \\+//' | xargs -d '\\n' -n 1 git branch -d # will not delete master if master is not checked out"]
}, {
"title": "List all branches and their upstreams, as well as last commit on branch",
"tip": "git branch -vv"
Expand Down Expand Up @@ -440,4 +440,4 @@
}, {
"title": "Preformatted patch file.",
"tip": "git format-patch -M upstream..topic"
}]
}]