At work, my flow for fixing something is creating a branch git checkout -b {GITUSERNAME}/ticket-{TICKET-NUMBER} so like git checkout -b oscar/ticket-1234. I was wondering if there was a way I could make it so I could do git nt 1234 to create a "new ticket branch" of 1234 and then git cot 1234 to "checkout ticket 1234".
            Asked
            
        
        
            Active
            
        
            Viewed 113 times
        
    0
            
            
         
    
    
        Oscar Godson
        
- 31,662
- 41
- 121
- 201
- 
                    Are you working in a specific shell, and tried making a native alias? Have you tried a bash/python/perl/`$yourLangOfChoice` script? Have you tried *something*? – admdrew Nov 14 '13 at 20:13
- 
                    Yeah, I can make a bash script that's invoked in git with `!`, but was looking at how to do this with gitalias. I read the docs and, honestly, I don't really understand it fully. Sorry :\ – Oscar Godson Nov 14 '13 at 20:30
- 
                    I've never used git aliases, but I personally would just try [some examples](https://git.wiki.kernel.org/index.php/Aliases) and figure it out from there. – admdrew Nov 14 '13 at 20:33
1 Answers
3
            This will do it. Add --global after config to make it global:
git config alias.nt '!f() { git checkout -b $(git config user.name)/ticket-${1}; }; f'
git config alias.cot '!f() { git checkout $(git config user.name)/ticket-${1}; }; f'
Note that this will only work if your user.name is one word!
 
    
    
        Ash Wilson
        
- 22,820
- 3
- 34
- 45