Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8235063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:40:41+00:00 2026-06-07T18:40:41+00:00

If I run a regular git command such as git checkout I get helpful

  • 0

If I run a regular git command such as git checkout I get helpful autocompletion of branch names when hitting the tab key.

I have a few git aliases which take branch names as parameters, and I’m wondering if there’s a way of getting the branch name autocompletion to work with them?

Edit:

Just to provide some clarification from the discussion in the comments, aliases with a direct mapping work fine, i.e.:

ci = commit
co = checkout

It’s ones that are a bit more involved and use $1 as a parameter that don’t, for example:

tagarchive = !f() { git tag archive/$1 origin/$1 && git push origin :$1 && git push origin archive/$1 && git branch -d $1; }; f
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:40:44+00:00Added an answer on June 7, 2026 at 6:40 pm

    For git aliases, the autocomplete function for the git command (__git()) uses a call to git config --get "alias.$1" to determine that equivalent autocomplete function. This works for simple mappings but will choke on more complex aliases.

    To get around this, define an autocomplete function with a name that matches your alias, i.e. _git_tagarchive(). The autocomplete function for git should pick that up and use it for autocompletion.

    For example:

    [me@home]$ git tagarchive <TAB><TAB>
    AUTHORS             gentleSelect/       .gitignore          LICENSE             test_multiple.html  
    cron/               .git/               index.html          README.md  
    [me@home]$ _git_tagarchive() {
    > _git_branch  # reuse that of git branch
    > }
    [me@home]$ git tagarchive  <TAB><TAB>
    enable_multiple          master                   origin/gh-pages          v0.1                     v0.1.3 
    FETCH_HEAD               ORIG_HEAD                origin/HEAD              v0.1.1                   v0.1.3.1 
    HEAD                     origin/enable_multiple   origin/master            v0.1.2 
    

    For a more permanent solution simply add the function definition to your bashrc file. Eg:

    _git_tagarchive() 
    {
        _git_branch
    }
    

    Note that I’ve simply reused the autocomplete function for git branch; you may wish to change this to something more suitable or write your own.

    More info

    This solution was identified based on an exploration of /etc/bash_completion.d/git.

    Typically, aliased git commands are handled by the __git_aliased_commands() function which parses the output of git config --get "alias.$1" to decide on the autocomplete function to use. Using a more complex shell command as the alias target would understandably foil this approach.

    Looking further, it appears the autocomplete function for git (_git()) chains in autocomplete function for subcommands by simple prepending the function with _git_ (with dashes (-) in the command replaced by underscores). This is done before __git_aliased_command() is checked so this is something we could use.

    _git ()
    { 
       # .....
       local completion_func="_git_${command//-/_}"
       declare -f $completion_func >/dev/null && $completion_func && return
    
       local expansion=$(__git_aliased_command "$command")
       if [ -n "$expansion" ]; then
           completion_func="_git_${expansion//-/_}"
           declare -f $completion_func >/dev/null && $completion_func
       fi
    
    }
    

    The approach I’ve gone for is therefore to ensure that a function that matches your alias exists, i.e. _git_tagarchive().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python script which I would like to run at regular intervals.
My working command to run regular backups: ditto -c -k --sequesterRsrc --keepParent ~/Library/'Application Support/MyProg'/
I have an app which has tasks that run on regular intervals. Instead of
I have a String, I wish to use Linq to run a regular expression
I have a div that I am trying to run a regular expression on
I've been using git for a few months and have never run into problems.
I'm trying to run a regular expression (Ruby) on a file containing code and
Is there another way to run a regular JS function with parameters passed than
When a regular expression is run JavaScript, is the regex engine that evaluates the
http://www.ddrewdesign.com/portfolio/ I've run that on three different VMs and my brother's regular (and very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.