GIT如何将我从master制作的更改放到dev分支?

时间:2018-05-23 08:06:21

标签: git github branch git-branch

所以我分叉了一个仓库,现在我对master分支进行了更改并发送了pull请求,我犯了一个错误,因为他们希望更改在另一个分支dev分支中完成。

如何将更改从master更改为dev并再次发送pull请求?

2 个答案:

答案 0 :(得分:0)

假设:

  • 你正在推销你的回购(不是共享)
  • 你是分支机构的负责人(你的工作已经完成)

使用一些图形工具来帮助您查看每件事情是否顺利(gitk;做“shift F5”以刷新视图,是一个不错的选择)

# on top of your dev : first create the dev branch
git checkout -b <dev-branch-name>
# then you must rewind where you would like master to be master
git checkout <sha 1 of position where master should be>
# at this point assign master head to here
git branch -f master
# now you have to push the two branches
# 1st dev branch
git push <remote-name> <dev-branch-name>
# then master note the -f force option
git push -f <remote-name> master

在每个点上,您都会在图形工具工具中检查它是否符合预期

答案 1 :(得分:0)

为什么不使用cherry-pick

我假设您当前的分支是master。如果是,请使用dev检查您确实要提交到git log的提交ID。然后你会看到这样的提交日志:

commit ca82a6dff817ec66f44342007202690a93763949
Author: AuthorName < author@gee-mail.com>
Date:   Mon Mar 17 21:52:11 2008 -0700

    changed the version number

commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
Author: AuthorName < author@gee-mail.com>
Date:   Sat Mar 15 16:40:33 2008 -0700

    removed unnecessary test code

如果您要将提交085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7应用于dev

git checkout dev
git cherry-pick 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7

之后,您可以再次发送拉取请求。

相关问题