有没有一种简单的方法可以更改到以前的活动分支?
我在 Windows 上使用 git(实际上是 msysgit)1.6.4。大多数时候我都在一些功能分支上工作。时不时地,我想跳回 master 来挑选我在功能分支中所做的一个特定提交 - 通常是因为它是一个有用的错误修复,即使没有该功能也有意义。我的工作流程是这样的 - 如果这不必要地复杂,请告诉我:-):
git checkout -b mycoolfeaturebranch // hack away, implementing a feature and one bugfix (while I'm at it) git add file_with_bugfix.cpp git commit -m "Fixed bug 12345 // commit the bugfix git checkout master // hop over to master git cherry-pick // bring the bugfix into master
此时,我通常想跳回到我的功能分支以继续处理该功能。不幸的是,我的分支名称往往会变得有点长(例如“mycoolfeaturebranch”),而且我在 Windows 上没有 git 分支名称选项卡补全功能。
Unix shell 上是否有类似 cd -
的东西(它会跳转到上一个目录,对于在两个目录之间切换很有用)? git checkout - 会很棒。 :-)
I'm using git (in fact, msysgit) 1.6.4 on Windows. Most of the time I'm doing work in some feature branches. Every now and then, I want to hop back to master to cherry-pick one particular commit I did in my feature branch - usually because it's a useful bugfix which makes sense even without the feature. My workflow is like this - if this is unnecessarily complicated, please tell me :-) :
git checkout -b mycoolfeaturebranch // hack away, implementing a feature and one bugfix (while I'm at it) git add file_with_bugfix.cpp git commit -m "Fixed bug 12345 // commit the bugfix git checkout master // hop over to master git cherry-pick // bring the bugfix into master
At this point, I usually want to hop back to my feature branch to continue work on the feature. Unfortunately, my branch names tend to become a little long (like, 'mycoolfeaturebranch') and I don't have git branch name tab completion on Windows.
Is there maybe something like cd -
on Unix shells (which hops to the previous directory, useful for toggling between two directories)? A git checkout -
would be great. :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 $GIT/Documentation/RelNotes-1.6.2.txt:
你尝试过吗?
From $GIT/Documentation/RelNotes-1.6.2.txt:
Did you try it?
尝试:
来自 git rev-parse< /a>:
正如 Stefan Näwe 在 他的答案:
尽管语法
@{-1}
已经在 1.6.2 左右出现,但直到 1.6.2 才完全有效,正如 Junio C. Hamano 评论 早在 2009 年 2 月(重点是我的):(注意:这与
@{}
不同)
Try:
From git rev-parse:
As mentioned by Stefan Näwe in his answer:
Even though the syntax
@{-1}
has been around 1.6.2, it is only since 1.6.2 it is fully effective, as Junio C. Hamano comments back in February 2009 (emphasis mine):(Note: that differs from
@{<n>}
)