Keeping a Git fork up-to-date

I sometimes contribute to open source projects on Github. The workflow then often consist of creating a fork, adding my own code and then submitting pull requests.p

Unfortunately sometimes when you do this the upstream (meaning, the ‘original’ repository) has changed so much that it’s not possible to easily submit (or include) your changes. You then need to sync your fork with the upstream repository.

For what concerns the repositories related to MISP, these are the commands that I then use (issued from within the directory containing your fork) :

cat .git/config | grep remote

This gives me all the “remote” (upstream) providers. The output should look similar as below.

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	remote = origin
[remote "MISP"]
	fetch = +refs/heads/*:refs/remotes/MISP/*
[remote "upstream"]
	fetch = +refs/heads/*:refs/remotes/upstream/*

In most (all?) of the MISP repositories you can choose “MISP”. I then fetch the changes from the original repository to update my local repository with these changes.

git fetch MISP
git pull MISP master

As a last step you can then push these changes back to your repository.

git push

Caution : the above commands do not take into account different branches etc. that you might have created. If you already know how to create a branch then most likely you are also aware of the above sync commands.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.