git merge 在一个命令中

发布于 2024-12-02 06:44:19 字数 256 浏览 3 评论 0原文

我现在住在A分行。我想将分支 A 合并到分支 B 并切换到分支 B,如何在一个命令中完成此操作?

现在我必须签出branch-B,并将branch-A合并到其自身中。 B/c 我在合并时保持 IDE 打开。当我签出另一个分支时,ide(xcode) 可以赶上文件的更改,并且通常会崩溃。我所做的合并通常是快进的。所以我想知道是否有一种方法可以在不更改文件的情况下进行快进合并,只需将 HEAD 和分支 B(通常是 dev 分支)设置为最新提交,谢谢

I'm now staying at branch-A. I want to merge branch-A into branch-B and switch to branch-B, how can I make this in one command?

Now I have to checkout branch-B ,and merge branch-A into itself. B/c I kept the IDE opened while merging.when I checkout another branch, the ide(xcode) can catch up the files' changing, and crashes usually. The merge I made usually goes with fast-forward.So I'm wondering if there is a way to make fast-forward merge without files' changing,just set the HEAD and branch-B(usually dev branch) to the lastest commit,thx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感性 2024-12-09 06:44:19

如果合并速度快进,您可以通过 在切换到合并到的分支之前,合并到 git 中的一个分支而不切换到它
然后可以通过别名来实现在 1 个命令中完成它。

Provided the merge is fast forward, you can solve the IDE problem by Merging to a branch in git without switching to it before switching to the merged-to branch.
Then doing it in 1 command can be achieved by aliasing.

撩人痒 2024-12-09 06:44:19

我真的不明白为什么输入两个命令这么麻烦:

git checkout branch-B
git merge branch-A

...但如果它真的太“挑剔”,你可以创建一个 git 别名来执行此操作。例如,尝试:

git config alias.whevs '!sh -c '"'git checkout \"\$1\" && git merge HEAD@{1}'"

然后您可以这样做:

git whevs branch-B

这将签出您作为参数提供的分支,然后合并到您所在的上一个提交中。

I really don't see why it's such a hassle to type two commands:

git checkout branch-B
git merge branch-A

... but if it's really too "fussy" you could create a git alias to do this. For example, try:

git config alias.whevs '!sh -c '"'git checkout \"\$1\" && git merge HEAD@{1}'"

Then you can just do:

git whevs branch-B

That'll checkout the branch you supply as a parameter, and then merge in the previous commit that you were at.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文