开发者

Creating a 'git publish' alias, but need to store temporary variable

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 a开发者_如何学Godvance.


Git checkout -

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜