0

I am cloning a github repository 'A' to my local github account 'B'. Then I make a local copy of 'B' on my computer with git clone.

Then I might make a change, create a pull request etc.

After some time, the original repo 'A' advances, changes are being made to the repo 'A'. It is now different of my repo 'B'.

Is there a git command so that I can update 'B' to the current version of 'A', and the local copy on ly computer as well?

So far, I removed the checkout on the computer (rm -rf), I deleted the fork 'B', and started from scratch again. Is there an easier way to do this?

Alex
  • 41,580
  • 88
  • 260
  • 469
  • 2
    Possible duplicate of [How do I update a GitHub forked repository?](https://stackoverflow.com/questions/7244321/how-do-i-update-a-github-forked-repository) – Schleis Apr 06 '18 at 12:45

2 Answers2

1

You will want to add the original repo as a second remote.
To do this, just run

git remote add <local name> <url>

so for example

git remote add github https://github.com/myrepo

After you have done this, you can update your repository by pulling changes from the second remote.

git pull github

You can read more about this here https://help.github.com/articles/fork-a-repo/#step-3-configure-git-to-sync-your-fork-with-the-original-spoon-knife-repository

lukas-reineke
  • 3,132
  • 2
  • 18
  • 26
0

Add the original repo as remote. Pull from that remote, or reset force if you need.

If you keep a local branch always pointing to the remote master, and don't touch it, you will be able to update that branch and then merge or rebase your local changes.

LuisGP
  • 431
  • 3
  • 13