简体   繁体   中英

customizing git commands in bash_profile to auto index to next branch

Below is my custom gitp command which works great (with psuedo-code). I would like to add to the script by having it automatically auto-index and checkout to a new branch. Hoping there is a command-line bash whiz who can figure it out! :)

    previous_branch_num = 0;
    gitp() {
      git add -A &&
      git commit -m "${1?'Missing commit message'}" &&
      git push      
      git checkout -b "v{++previous_branch_num}" //<--psuedo code
    } 

Simply:

#!/bin/bash

previous_branch_num=0

gitp() {
  git add -A &&
  git commit -m "${1?'Missing commit message'}" &&
  git push      
  git checkout -b "v$((++previous_branch_num))" # <-- real code
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM