基于这篇文章,我想创建一个类似的别名(流程如下所述)。由于作者/文章的评论被禁用,我想我应该在这里问。假设您位于“主题”分支上,我想修改流程以执行以下操作:
- 检测并将当前分支名称存储在 $branch 中(使用 此处)
- 切换回 master 分支
- 从远程拉取
- 切换回 $branch
- 将 $branch 重新设置为 master 的基准
- 切换回掌握
- 合并来自 $branch 的更改
- Run wtf
伪别名可能类似于(知道对 $branch 的引用很可能是错误的):
branch-name = !git for-each-ref --format='%(refname:short) ' git symbolic-ref HEAD
发布 = !git 分支名称 > $分支&& git checkout master && git pull && git checkout $branch && git checkout $branch && git rebase master && git checkout master && git merge $branch
有办法解决这个问题吗?我不知道如何存储/使用 $branch 变量(注意,来自 windows/c#/VSS 背景,所以在 git 中仍然很绿色)。
最后一点,我在 Windows Powershell 控制台窗口中使用 git。
提前致谢。
Based on this article I wanted to create a similar alias (flow described below). With the author/article's comments disabled, I thought I'd ask it here. Assuming you are on a 'topic' branch, I'd like to modify the flow to do the following:
- Detect and store the current branch name in $branch (using alias from here)
- Switch back to master branch
- Pull from remote
- Switch back to $branch
- Rebase $branch against master
- Switch back to master
- Merge changes from $branch
- Run wtf
A psuedo alias might be something like (knowing that the references to $branch are most likely wrong):
branch-name = !git for-each-ref --format='%(refname:short)' git symbolic-ref HEAD
publish = !git branch-name > $branch && git checkout master && git pull && git checkout $branch && git rebase master && git checkout master && git merge $branch
Is there anyway to pull this off? I've no idea how to store/use the $branch variable (note, coming from a windows/c#/VSS background so pretty green in git still).
Final note, I am using git from within a Windows Powershell console window.
Thanks in advance.
发布评论
评论(1)
将签出之前的分支,因此您不需要存储它。
当你确实需要它时,你可以从 .git/HEAD 获取它
希望这会有所帮助
will checkout the previous branch, so you don't need to store it.
When you do need it, you can get it from .git/HEAD
Hope this helps