Search code examples
gitgithubversion-controlrepositorygit-fork

What happens when we 'fetch upstream' a forked repository?


I am learning GitHub and found downstram/upstream concepts for forked repositories. I also went through various documentations/blogs but was not able to clear that what actually happens when we press 'fetch upstream'?


Solution

  • git fetch upstream fetches ("downloads") all the changes from the remote repository upstream and stores them locally with the upstream. You can then refer to these local copies (e.g., check out to them, set up tracking branching, cherry pick commits, etc) with this prefix. E.g., git checkout upstream/some-branch would check out to the local copy of some-branch you just fetched from upstream.