git - When creating new branch, How to extend branch name from the existing branch (include example)
问题描述
for example, I have an existing branch that name is issue_12345
then I want to create another branch with naming issue_12345_features
,
Is there an easy way to create a new branch referencing from the current branch name? (for example, Now I am in issue_12345 and want to create a branch starting from this current branch, the name start from the current branch name).
解决方案
The following commands work in Bash and PowerShell.
Git 2.22 and above:
To just create a branch:
git branch "$(git branch --show-current)_features"
To create a branch and checkout to the new branch in a single command:
git checkout -b "$(git branch --show-current)_features"
Git version older than 2.2:
Replace git branch --show-current
with git rev-parse --abbrev-ref HEAD
:
git branch "$(git rev-parse --abbrev-ref HEAD)_features"
or
git checkout -b "$(git rev-parse --abbrev-ref HEAD)_features"
推荐阅读
- database - 从 Azure Cosmos DB(类型为 MongoDB API)导出数据
- ruby-on-rails - Ruby/Rails - 链接未知数量的方法调用
- python - ttyd 的烧瓶代理
- terraform - 使用 terraform 检索 azure api 管理资源时出现错误设置“hostname_configuration”
- c - 为什么我没有收到分段错误?
- angular - Ngxs 状态文件中的服务调用
- http - 如何像在 curl 中一样在 clojure http 请求中设置“无代理”?
- excel - 计算具有多个条件的行
- java - log4j 根据应用程序的登录用户在不同文件中添加日志
- javascript - 如何将从输入字段中获取的画布名称与 Javascript 中的画布合并?