How to merge recent changes from base repo to forked repo

2 years ago I split the git repository. After that, we made some changes on our side not so much, but we changed the little things in many files.

Now in the git repo database, from which we were forked, there are some fixes + functions. Now we want to incorporate these changes into our forked, while maintaining constant local changes.

Is there a way to merge the latest repo changes into our forked repo while keeping our local changes?

0
source share
2 answers

If changes are highlighted on their own branch, you can simply push the changes up from the repository.

git pull 

Remember that this is equivalent to the git fetch && git merge operation.

If you want to include these new changes in your specific branch, you will have to merge them through git merge . Keep in mind that with codebase changes of more than two years, you are likely to encounter merge conflicts. At this point, you will want to find out what has changed from the old API to the new API and determine the best way forward.

+1
source

In addition to Makoto's answer, which describes how git merge changes from a repo base branch to a branch branch, you can also consider doing git rebase . Consider the following diagram:

 base branch: A <- B <- C your branch: A <- D <- E <- F 

If you git rebase branches on a base branch, then your branch will look like this:

 your branch: A <- B <- C <- D' <- E' <- F' 

rebase allowed you to retrieve all the changes from the base branch, while maintaining the same commits that you had on your branch, and in the same order that you did in the last two years. I donโ€™t know if this was what you had in mind when you said โ€œkeeping our local changes as they are,โ€ but that might fit the bill.

You will probably also have merge conflicts, as with the merger, so get ready for the tedious fun.

+1
source

Source: https://habr.com/ru/post/984175/


All Articles