简体   繁体   English

GIT如何将我从master所做的更改更改为dev分支?

[英]GIT how to put changes i made from master to dev branch?

So I forked a repo now I made changes to master branch and sent pull request, I made a mistake because they want the changes to be done in a different branch, the dev branch. 因此,我分叉了一个仓库,现在我对master分支进行了更改并发送了pull请求,我犯了一个错误,因为他们希望在另一个分支dev分支中进行更改。

How do I put the changes from master to dev and send pull request again? 如何将更改从master转移到dev并再次发送请求请求?

assuming : 假设 :

  • you are pushing to your repo (not a shared one) 您正在推送到您的仓库(不是共享仓库)
  • you are on head of your branch (where your job is finished) 您在分支机构的负责人(您的工作已完成)

Use some graphical tool to help you seeing if every thing goes well (gitk ; doing "shift F5" to refresh view , is a good option) 使用一些图形工具来帮助您查看是否一切顺利(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

At each point you check in the graphical tool tool that it does what is expected 在每一点上,您都要检查图形工具是否完成了预期的工作

Why not use cherry-pick ? 为什么不使用cherry-pick

I will assume that your current branch is master . 我将假设您当前的分支是master If so, You check for the commit ID that you really want to commit to the dev using git log . 如果是这样,则使用git log检查您确实要提交给dev人员的提交ID。 Then you see the commit logs like this: 然后,您会看到如下的提交日志:

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

If you want to apply the commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 to the dev . 如果要将提交085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7dev

and

git checkout dev
git cherry-pick 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7

After that, you can send pull request again. 之后,您可以再次发送拉取请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将我的更改从分支副本 dev 分支推送到主 git 组织? - How do I push up my changes to a master git organization from a forked copy dev branch? Git:如何通过dev中的更改保持本地功能分支更新? - Git: How to keep local feature branch updated with changes made in dev? 如何将我在分支中所做的更改推送到主分支? - How do I push changes I made in a branch into the master branch? Git:如何有选择地将更改从主复制到分支? - Git: How do I selectively copy changes from master to branch? 如何将git更改从master应用于其他分支? - How do I apply git changes from master to different branch? 如何撤消我在git分支中所做的更改? - How to undo the changes I made in a git branch? Git:如何将分支和分支的分支更改为master? - Git: How should I get changes of a branch and a branch of a branch into master? git:如何用&#39;dev&#39;分支中的文件更新&#39;master&#39;分支? - git: How to update 'master' branch with a file from the 'dev' branch? Git - 从 master 获取更改并将它们放在我的分支上 - Git - get the changes from master and put them on my branch git 问题:继续将主分支更改拉入从功能分支分支出来的单个开发分支是否更好? - git question : is it better to keep pulling master branch changes into individual dev branch branched out from a feature branch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM