开发者

How do you merge two git branches that are in different local repos/folders?

开发者 https://www.devze.com 2023-01-10 07:29 出处:网络
I have: folder_a/app_1.0 folder_b/app_1.1 And let\'s just say I\'m working off of the master branch in both folders/r开发者_运维问答epos.

I have:

folder_a/app_1.0
folder_b/app_1.1

And let's just say I'm working off of the master branch in both folders/r开发者_运维问答epos.

How can I merge the branches together?


You must pull the commits from one repository into the other, do the merge, then pull back into the first (if you want both repositories to contain all the commits).

# switch to repo A
cd folder_a

# Add repo B as a remote repository
git remote add folderb /path/to/folder_b

# Pull B's master branch into a local branch named 'b'
git pull folderb master:b

# Merge b into A's master branch
git merge b

# Switch to repo B
cd ../folder_b

# Add repo A as a remote repository
git remote add foldera /path/to/folder_a

# Pull the resulting branch into repo B's master branch
git pull foldera master:master
0

精彩评论

暂无评论...
验证码 换一张
取 消