【问题标题】:GIT how to put changes i made from master to dev branch?GIT 如何将我从 master 所做的更改放到 dev 分支?
【发布时间】:2018-11-02 03:04:51
【问题描述】:

所以我创建了一个 repo,现在我对 master 分支进行了更改并发送了 pull request,我犯了一个错误,因为他们希望在不同的分支中完成更改,dev 分支。

如何将更改从 master 放到 dev 并再次发送 pull request?

【问题讨论】:

标签: git github branch git-branch


【解决方案1】:

假设:

  • 您正在推送到您的 repo(不是共享的)
  • 你是你的分支的负责人(你的工作已经完成)

使用一些图形工具来帮助您查看是否一切顺利(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

在每个点您检查图形工具工具是否符合预期

【讨论】:

    【解决方案2】:

    为什么不使用cherry-pick

    我假设您当前的分支是master。如果是这样,您使用git log 检查您真正想要提交到dev 的提交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
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-17
      • 2019-08-04
      • 2023-03-26
      • 2011-01-20
      • 2016-03-07
      • 2017-06-26
      • 1970-01-01
      • 2011-07-17
      相关资源
      最近更新 更多