将多个 git 分支合并到 master 中?

发布于 2024-08-13 04:09:44 字数 314 浏览 7 评论 0原文

所以我有 3 个 git 分支:

  • master
  • refresh
  • auth_upgrade

我还没有像我应该的那样使用分支...所以 master 已经过时了,refresh 有点过时了,而 auth_upgrade 实际上是完全最新的分支。

所以...我最终希望将 auth_upgrade 设为 master 分支,然后将其 git push 到我的 github 存储库。

这样做的最佳流程是什么?

So I have 3 git branches:

  • master
  • refresh
  • auth_upgrade

I haven't really been using branches like I should...so master is way out of date, refresh is somewhat out of date and auth_upgrade is actually the branch that is completely current.

So...I ultimately want to make auth_upgrade the master branch and then git push it to my github repo.

What's the best process for doing that?

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

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

发布评论

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

评论(3

旧街凉风 2024-08-20 04:09:44

您可以将 auth_upgrade 拉入 master

$ git co master
$ git pull . auth_upgrade
  • 然后在 master 上执行主线工作,并使用此分支与您的远程同步。
  • 如果您想要包含一些独特的更改,则将相同的过程应用于refresh

看:

$ man git-pull

    git-pull - Fetch from and merge with another repository or a local branch

You could pull auth_upgrade into master.

$ git co master
$ git pull . auth_upgrade
  • then do mainline work on master and use this branch to sync with your remote ..
  • apply the same procedure to refresh, if there are some unique changes you want to include ..

see:

$ man git-pull

    git-pull - Fetch from and merge with another repository or a local branch
撞了怀 2024-08-20 04:09:44

您可以使用 git 分支重命名分支 - m 选项:

git branch -m master old_master
git branch -m auth_upgrade master

You can rename branches with the git branch -m option:

git branch -m master old_master
git branch -m auth_upgrade master
拥抱我好吗 2024-08-20 04:09:44

如果当您说“过时”时,旧分支是严格的祖先,那么您实际上并没有任何合并问题。

如果您只想将当前分支放入远程存储库上的 master 分支,您只需执行以下操作:

git push origin HEAD:master

编辑: 根据您的评论之一,听起来您没有来自远程的所有更改不过,您可能需要在当前分支中合并它们,然后才能成功推送:

git fetch
git merge origin/master

然后您可以删除本地分支。使用小-d删除是安全的,因为它只删除当前分支的祖先分支。

git branch -d master
git branch -d refresh.

如果您对本地分支不被称为 master 感到困扰,您现在可以执行以下操作:

git checkout -b master
git branch -d auth_upgrade

If when you say 'out of date' the old branches are strict ancestors then you don't really have any merge issues.

If you just want to make your current branch into the master branch on your remote repository you can just do:

git push origin HEAD:master

Edit: from one of your comments it sounds like you don't have all of the changes from remote master in your current branch, though, so you may need to merge them in before pushing successfully:

git fetch
git merge origin/master

You can then delete you local branches. delete with a small -d is safe in that it only deletes branches that are ancestors of your current branch.

git branch -d master
git branch -d refresh.

If it bothers you that your local branch isn't called master you can now do:

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