linux - 在 bash_profile 中自定义 git 命令以自动索引到下一个分支
问题描述
下面是我的自定义 gitp 命令,效果很好(使用伪代码)。我想通过让它自动自动索引并结帐到新分支来添加到脚本中。希望有一个命令行 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
}
解决方案
简单地:
#!/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
}
推荐阅读
- php - php在实例化类中设置变量值
- asp.net-core - Microsoft/dotnet 中没有 rsync 命令:最新图像
- r - 从具有跨多个页面的表格的网页中抓取信息
- python - 如何将不需要的值变为 0?
- attachment - 如何在corda中上传文件,附加和下载?
- python - 根据行条件替换 nan 值
- python - 我可以获取 DataFrame 中给定位置的字符串索引和列名吗?
- python - 使用 python 遍历 json dict/object
- mongodb - 使用容器 ip 从另一台主机访问 mongodb 容器
- http - 查询字符串以识别资源