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

some new aliases suggestions #55

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

romain-dartigues
Copy link
Contributor

@romain-dartigues romain-dartigues commented Sep 4, 2019

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

gitalias.txt Show resolved Hide resolved
gitalias.txt Show resolved Hide resolved
@romain-dartigues
Copy link
Contributor Author

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

@joelparkerhenderson
Copy link
Member

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

@romain-dartigues
Copy link
Contributor Author

romain-dartigues commented Nov 3, 2021

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)"

@joelparkerhenderson
Copy link
Member

joelparkerhenderson commented Nov 4, 2021

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?

@romain-dartigues
Copy link
Contributor Author

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.

@joelparkerhenderson joelparkerhenderson force-pushed the main branch 21 times, most recently from 99a600e to 72ab030 Compare January 11, 2022 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants