简体   繁体   中英

Git add remote repo as a site

I have a repo called live.git and I have another repo called dev.git.

I want to add the dev.git repo as a branch to live.git so that I can see what's different on dev.git and possibly merge some changes to live.git.

I'm still new to git and I feel like I'm missing something obvious.

I am not looking to keep the history of both repositories, my end goal is to have the differences from dev.git committed to live .git and remove the branch.

You can't add repositories as branches. To do what you're trying you can add it as a remote.

In live.git do git remote add dev /path/to/dev.git . You'll then be able to do git fetch dev and use git diff to see differences between repos.

Assuming you're on your live repo:

# Add dev repo as a remote source
$ git remote add dev git://path/to/dev.git

# Make a new dev branch, on the live repo
$ git checkout -b dev

# Merge in your dev repo using all of "their" code in conflicts
$ git merge dev/master -s theirs

# Commit and compare
$ git commit -am "dev repo merged in"
$ git diff master

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM