When you collaborate in an open source project it is likely to be asked to make a fork of one repository. A fork is a copy of the project in your GitHub account. This duplicate allows you to freely experiment with changes without affecting the original project.

There is a problem when you fork a project, it is not going to have the last changes made in the original one, so in order to avoid problems when you try to push your changes it is better to keep your fork up to date.

Here’s how.

Synchronizing Your Forked Project

Once you have forked the repository, clone it in your local machine. Go to the directory of the project and list the current configured remote repository for your fork.

$ git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)

Specify a new remote upstream repository that will be synced with the fork.

$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

Verify the new upstream repository you've specified for your fork.

$ git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
> upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
> upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)

Fetch the branches and their respective commits from the upstream repository.

$ git fetch upstream
> remote: Enumerating objects: 82, done.
> remote: Counting objects: 100% (82/82), done.
> remote: Compressing objects: 100% (44/44), done.
> remote: Total 91 (delta 53), reused 30 (delta 30), pack-reused 9
> Unpacking objects: 100% (91/91), done.
> From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY
> * [new branch] master -> upstream/master

Check out your fork's local master branch.

$ git checkout master
> Switched to branch 'master'

Merge the changes from upstream/master into your local master branch.

$ git merge upstream/master
> Updating a422352..5fdff0f

The latest changes done in the original repository are now in your local project. Keep in mind that to update your fork on GitHub, you must push your changes.

Finally...

Don’t forget It’s important to keep your fork up to date in order to avoid merge conflicts or losing your work completely when you try to push your changes. So if you are starting to collaborate in an open source project and you would like to know more information about forks and upstreams click here

Learn More about Encora

We are the software development company fiercely committed and uniquely equipped to enable companies to do what they can’t do now.

Learn More

Global Delivery

READ MORE

Careers

READ MORE

Industries

READ MORE

Related Insights

Exploring Digital Wallet Growth in Latin America: What's Next?

Digital wallets are transforming the global financial landscape, enabling individuals and ...

Read More

How AI Can Augment Telecom Network Management Capabilities

Digital connectivity is essential to our daily lives, and telecom operators face unprecedented ...

Read More

Unlock Profit: Data-Driven Hospitality Revenue Strategies

Have you ever wondered why hotel rates spike during festivals or drop midweek? The answer lies in a ...

Read More
Previous Previous
Next

Accelerate Your Path
to Market Leadership 

Encora logo

Santa Clara, CA

+1 669-236-2674

letstalk@encora.com

Innovation Acceleration

Speak With an Expert

Marketing Form
This event has not started.
This event is fully booked
This event has ended.
All sessions are fully booked but you can still register for the event.

Speak With an Expert

Encora needs the contact information you provide to us to contact you about our products and services. You may unsubscribe from these communications at any time. For information on how to unsubscribe, as well as our privacy practices and commitment to protecting your privacy, please review our Privacy Policy.

Encora logo

Santa Clara, CA

+1 (480) 991 3635

letstalk@encora.com

Innovation Acceleration