简体   繁体   English

自定义bash_profile中的git命令以自动索引到下一个分支

[英]customizing git commands in bash_profile to auto index to next branch

Below is my custom gitp command which works great (with psuedo-code). 以下是我的自定义gitp命令,该命令非常有效(使用伪代码)。 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! 希望有一个命令行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}" //<--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
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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