Tonight was a rainy, cold night in my town, so I spent the evening trying to get my four pull requests in for Digital Ocean’s Hackoberfest. I found myself updating an old fork on my Github page and reflecting on the questions I had when starting with Git and Github. How to update my personal fork on Github from the original repository was one of my first tasks I learned, and I thought I’d take the opportunity to pass the knowledge along in the spirit of Hackoberfest.
I have a fork of Kubernetes in my Github account for preparing pull requests. I can clone my repository to my development workstation using git clone:
The URI used in the git clone command is stored as a remote named origin. We can verify this very easily using git remote:
This remote named origin is the repository location we are referring to when we perform git push origin master or git pull origin master. origin is only one possible location, and we can add other remote repositories such as the upstream repository that we’d like to pull data from. Let’s add the main Kubernetes repository as a remote named upstream using git remote add.
We can now easily update our code from the upstream Kubernetes repository with a simple git pull. You can then push your repository to origin to update your forked repository.
Excellent work! Our forked repository is now up to date with the upstream repository, and we’re ready to hack on our favorite project!