
It looks like this: git fetch upstream remote: Counting objects: 6427, done. To bring the repo up to date, we can now fetch the latest from the upstream repo. git remote -v origin (fetch) origin (push) (fetch) (push) Fetching the latest You can use -v as a shortcut for -verbose. git remote add upstream if we inspect the repo’s remotes again, we will see both the origin and the upstream. By convention this remote is called “upstream” though you can call it whatever you want. Find the original repo’s URL and add it as a new remote. To do this, we use the remote command again, this time to add a new remote. Instead, add the upstream repository as another remote for the repo and work with it from the command line. You could delete your fork and go through the process of forking and cloning the repo again, but that’s a lot of unnecessary work.
#GIT FETCH UPSTREAM UPDATE#
You need to update your fork so that you’re working with the latest code. Sometime later down the line you find you want to make another pull request, but the original repo has moved on.

Then you can create your pull request and hope it gets accepted. Setting up your changes is covered by the six commands Cory listed in his tweet you create a new branch with branch, checkout the branch, make the changes you want, commit as many times as necessary and finally push the branch to the origin, your fork. That keeps the master branch clean and makes it easy to keep up to date. When contributing something back to the repo, it is easiest to do so on a branch. That’s better, this shows that the remote repository is the one we cloned and that we can fetch from and push to it. Running it again with the -verbose flag shows a bit more information: git remote -verbose (fetch) (push) OK, that’s not too useful, it just shows we have one remote repo called “origin”. Run git remote in the twilio-node directory and we see the following: git remote origin After forking, we clone the repo: git clone can now see the first use case for remote. Let’s use a repo I have forked as an example: Twilio’s Node.js package.

To work with the project you then clone the repository to your own machine. When you fork a project, you make a copy of it under your own namespace.

What if you want to fork and contribute to an open source project on GitHub, GitLab or BitBucket though? You’re going to need a few more commands so that you can keep your fork up to date, namely remote, fetch and merge. You can be quite productive in Git with around 6 commands:Īnd it’s true, you can do most of your work with those commands. I thought I needed to understand all its powerful features to be productive. But honestly, it intimidated me for years. I’ve seen the following tweet about git making its way around Twitter recently:
