Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a forked git repo?

I have forked a git repo. Is the forked repo automatically updated if the origin has updates? Or should I perform some commands in cmd to make this forked repo updated? What are this commands?

like image 620
Lizza Faith Avatar asked Aug 09 '12 01:08

Lizza Faith


People also ask

How do I update my forked library?

Go to your GitHub account, under your forked repository. Click the compare and pull request button. And you are done. Wait for your content to be reviewed, make changes where necessary and your pull request will be merged to the team project.

Can I make changes in forked repo?

About forks A fork is a copy of a repository that you manage. Forks let you make changes to a project without affecting the original repository. You can fetch updates from or submit changes to the original repository with pull requests.


1 Answers

They have very specific help on this topic on the github docs: https://help.github.com/articles/fork-a-repo

Configure remotes

When a repo is cloned, it has a default remote called origin that points to your fork on GitHub, not the original repo it was forked from. To keep track of the original repo, you need to add another remote named upstream:

git remote add upstream https://github.com/octocat/Spoon-Knife.git
# Assigns the original repo to a remote called "upstream"

git fetch upstream
# Pulls in changes not present in your local repository, 
# without modifying your files

Pull in upstream changes

If the original repo you forked your project from gets updated, you can add those updates to your fork by running the following code:

git fetch upstream
# Fetches any new changes from the original repo

git merge upstream/master
# Merges any changes fetched into your working files
like image 177
jdi Avatar answered Oct 06 '22 15:10

jdi