Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 1.03 KB

git-diffrepository-synbranch.md

File metadata and controls

40 lines (26 loc) · 1.03 KB

Here we want to merge a different branch from another repository.

Usecase

eg. When you forked a repository and you want to synchronize it with the origin repository someday.

Commands

// Clone repository
git clone https://xxx/xxx/xxx.git

// Checkout branch for merge, here do not merge on master branch directly
git checkout -b master-merge origin/master

// Take a look at the current upstreams
git remote -vv

// Add another repository upstream named forigin
git remote add forigin https://yyy/yyy/yyy.git

// Fetch "forigin"
git fetch forigin

// Confirm branches and it`s related remote
git branch -avv

// Here assume we want to merge forigin/master branch into master-merge branch
git merge forigin/master
git add .
git commit -m 'xxxxxx'

// When there is no conflict then checkout master , do merge and delete master-merge branch
git checkout master
git merge master-merge
git branch -d master-merge

// Push to remote repository
git push