Home:ALL Converter>How to merge one remote branch into another remote branch?

How to merge one remote branch into another remote branch?

Ask Time:2014-04-28T16:33:58         Author:Zorgiev

Json Formatter

I would like to know how to merge one remote branch into another remoter branch and have the previous one removed right after the merge applied.

Author:Zorgiev,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/23336221/how-to-merge-one-remote-branch-into-another-remote-branch
chaiyachaiya :

From what I understand, you have one remote foo, containing branch_1 and branch_2.\nFirst, we can't do merge operation remotly. \nWe have to track the remote repository, do the operation we want locally (such as merging branches) and then push our new snapshot to the server.\n\nIe: \n\n\ngit clone [repo_adress]\n\n\nYou are on the master branch.\n\n\nYou can then checkout or create other branches and do your work in it.\n\n\nNow suppose we have the two branches branch_1 and branch_2. You want to merge branch_1 into branch_2 and then delete branch_1.\n\nYou checkout to branch_2 and then merge branch_1 with it:\n\n$ git checkout branch_2\n$ git merge branch_1\n\n\nFrom there either the merge is smooth or you've got conflict.\nOnce the merge is done, you can delete the merged branch i.e branch_1 by doing:\n\n$ git branch -d branch_1\n\n\nAnd then push your work:\n\n$ git push\n\n\nIn case branch_2 doesn't exist on the remote, you've got to create it:\n\n$ git push -u foo branch_2\n\n\nNote that deleting branch_1 locally doesn't delete it remotely (considering that it exists on the remote).\nTo do so, we are going to say to git: \"push nothing to the branch i want to delete\" ie:\n\n$ git push remote_name :branch_name\n\n\nTo read like git remote push remote_name \"nothing\":branch_name.\n\nNow is there any mean to do it automatically?\n\nI don't know (although I would investigate post merge \"git hook\"), but I'm not sure we ought to wish it. Deleting branches on remote is somewhat hazardous. Doing so manually is a good way to be sure of what we are doing.",
2014-04-28T09:52:31
Riddhi :

You can switch to the tracking branch(a local branch which represents your remote branch) in which you want to merge another branch by using the following command \n\ngit checkout origin/name_of_your_branch\n\n\nAfter that merge the another remote branch \n\ngit merge origin/brach_name_you_wanted_to_merge\n\n\nAfter that, if any conflicts occur, solve it. and after that just commit and push.\n\nand now checkout to your local branch. by the following command\n\ngit checkout name_of_your_brnach\n\n\nAfter that pull the origin by using git pull command. that's it.",
2018-08-08T13:56:30
yy