gitalias icon indicating copy to clipboard operation
gitalias copied to clipboard

some new aliases suggestions

Open romain-dartigues opened this issue 6 years ago • 5 comments

bv

List branches along their description (or make git be more useful):

$ git bv
2019-09-05/10-55-09           4cf70a1  Add: backup-branch
backup/2019-09-04/15-56-29    4cf70a1  Add: backup-branch
master                        160fbe8  Fix commit-{parents,is-merge} and simplify
propositions *                7dabc91  Add: backup-branch                          (description of my branch)

fix

A shorthand to stash/rebase/unstash:

$ git fix 3f5b450

backup-branch

Backup current branch prior a dangerous (i.e.: rebase) operation:

$ git backup-branch
$ git branch
  backup/2019-09-04/15-56-29
  master
* propositions

romain-dartigues avatar Sep 04 '19 13:09 romain-dartigues

I saw my be has been adopted as bsd (6296ef4f43d41e6fce2b4cd477dcaa72a9c4b257)! But I though the br was useful; should it be renamed?

romain-dartigues avatar Nov 02 '21 09:11 romain-dartigues

Yes. How about "'bb" because your idea is so useful, and "bb" doesn't conflict with anything else AFAIK? (Many teams use "br" as an alias for "branch").

Take a look at this code below, that aims for the same purpose, and see what you think of it:

git branch -v | 
while IFS= read -r x; do printf %s\\n "$x"$(git config "branch.${${x:2}/ */}.description"); done

joelparkerhenderson avatar Nov 03 '21 01:11 joelparkerhenderson

Many teams use "br" as an alias for "branch"

That my point (and there is already b for that purpose) ;^) but ok.

Take a look at this code below, that aims for the same purpose, and see what you think of it:

I have not been able to make it work :^( Plus there is some bashisms I'd like to avoid. I suppose I could achieve roughly the same thing as you with:

git branch "$@" --format='%(refname:short) %(HEAD)%09%(objectname:short)%09%(contents:subject)'|
while read -r l
do
  d=$(git config "branch.${l%% *}.description")
  echo "$l${d:+ ($d)}"
done|
column -ts"$(printf \\t)"

romain-dartigues avatar Nov 03 '21 06:11 romain-dartigues

Yes the "br" alias is a glitchy one, in practice; when I coach teams that already have the "br" already, frequently the teammates feel unsettled by replacing/amending/altering it.

Great point about avoiding bashisms. Your way is better than my way.

Your new code is significantly better IMHO because it's much clearer. And the column command with tabs works well.

If I forego the head star, commit hash, and subject, then the code could be be:

git branch "$@" --format='%(refname:short)' |
while read l
do
	d=$(git config "branch.${l}.description")
  	printf %s\\t%s\\n "$l" "$d"
done |
column -ts"$(printf \\t)"

When I try the code on some of my own repos, your approach looks very good to me. The column table layout makes it very obvious which branches have descriptions, and which branches don't.

What do you think?

joelparkerhenderson avatar Nov 04 '21 02:11 joelparkerhenderson

I don't mind the name of the alias (after all we all pick whatever is convenient for us from the gitalias.txt), I modeled br from my own interpretation of the directives (and I choose bv for git branch -v).

I would have reserved bb to the shorthand of "backup branch", but anyway.

romain-dartigues avatar Nov 10 '21 19:11 romain-dartigues