Search code examples
gitgithubgit-pullgit-fetch

How do I pull merged changes from a sub-branch back onto the original branch locally?


I created a branch. Let’s call it feat/feature1.0.

My friend created a branch off of this branch. Let’s call it feat/feature1.1.

My friend has committed and merged their changes into the original branch (feat/feature1.0).

I now want to pull the changes back to my local repository. How do I do this? I’ve tried a git pull, fetch, etc. I don’t want to cherry-pick since the changes already synced on the remote branch and are visible in the PR from the original branch into main. I just want to pull the changes locally.

I tried a git pull, git fetch --all, and git fetch origin.


Solution

  • git pull or git pull origin feat/feature1.0 should bring the changes in from the remote repo into your local repo. Both of these will pull changes to your local repo, but they would also update your current branch ( assuming you are on the local branch feat/feature1.0) with the changes made to the remote repo version of that branch.

    That said there could then be problems because you might have commits made locally that you hadn't on your branch.

    Also clean up your terminology you dont want to pull the changes locally, you want the changes incorporated properly into your branch. That is done through a merge. pull is a fetch and a merge. Another argument and philosophy that I won't go any deeper with is rebasing your local version of feat/feature1.0 based on the remote branch. That's a whole seperate can of worms.

    Without you providing more information there's nothing else we can do to help?

    What is the hash of your local branch? whats the hash on your box of origin/your_branch? What does GitHub show as the latest commit on the branch is?