0

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.

How do I put the changes from master to dev and send pull request again?

einverne
  • 6,454
  • 6
  • 45
  • 91
  • 1
    Check this question: https://stackoverflow.com/questions/5340724/get-changes-from-master-into-branch-in-git –  May 23 '18 at 08:11
  • Possible duplicate of [Get changes from master into branch in Git](https://stackoverflow.com/questions/5340724/get-changes-from-master-into-branch-in-git) – phd May 23 '18 at 16:09

2 Answers2

0

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)

# 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

jo_
  • 8,324
  • 1
  • 18
  • 14
0

Why not use cherry-pick?

I will assume that your current branch is master. If so, You check for the commit ID that you really want to commit to the dev using git log. 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.

and

git checkout dev
git cherry-pick 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7

After that, you can send pull request again.

Kazunori Takaishi
  • 2,268
  • 1
  • 15
  • 27