Sometimes your local repo and remote fork will get so far out of date that it's easier to start over fresh. This is especially useful when the original project makes a major change like updating the default branch. This section will explain how to delete the right things so you can begin again at the same point as the original project.
There are four steps to this process. You'll want to delete two things: your local clone, and your fork. Following that, you'll fork the repository again, and create a new local clone.
For this section, I'm going to work with the Adafruit CircuitPython Pypixelbuf repository.
The first step is to delete your local clone. Your local clone is the directory into which you cloned the repository in the first place. This action will remote the local copy of the repository from your computer.
You can use the command line to delete the directory. First,
cd to the directory that contains your Git directories, in my case
~/repos/. Then delete the desired directory by running the following command, replacing
your_repo_directory_name with the directory you wish to delete:
rm -rf your_repo_directory_name
Alternatively, you can use your file explorer to delete the directory.
Now that your local clone is deleted, it's time to delete your remote fork.
The next step is to delete your remote fork. This is done through GitHub. In your browser, navigate to your remote fork. You can do this multiple ways. This is one option.
Navigate to the original project repo. Find the Fork button in the upper right corner of the screen. Next to it is a number (the total number of forks made by everyone who has forked this project). Click the number next to Fork.
This will take you to a list of all of the forks of that repository, in the form of a list of links. Find your GitHub user ID in the list to find your fork. Click the link next to your name to go to your forked repository.
Once in your fork, click Settings.
Scroll down on the first page of Settings until you find Danger Zone. At the bottom of the Danger Zone, you'll find a button that says Delete this repository. Click the Delete this repository button.
Clicking the button will bring up a dialog box. You cannot click the button at the bottom until you enter the full name of the repository, including your GitHub user ID. Enter the full name of the repository including your GitHub user ID, and click the "I understand the consequences, delete this repository" button.
You may be asked to verify your two-factor authentication (if enabled) or enter your password to continue. This will take you back to your main GitHub page including a banner indicating you have successfully deleted the repo.
Now that you've deleted your fork, it's time to fork again.
Now, you'll want to fork the repo again. Navigate to the repo in your browser. This time, click the Fork button.
This will bring up a dialog box asking "Where should we fork repo_name?" where repo_name is the name of the repository you're forking. Click on your GitHub user ID.
GitHub will begin the process of forking the repository. This can take a few seconds.
You will then be directed to the main page of your new fork.
Now it's time to create a new local clone.
Now that you've forked the repository again, it's time to download a copy of the repo to your computer so you can begin working with it again. I will quickly go over the cloning process. For a detailed explanation, please see the Clone Your Repo section of the Grab Your Fork page in this guide.
First, get the URL. Click the green Code button on your fork of the repo on GitHub, and copy the .git URL, e.g.
Next, from within the directory where you store your Git repos, run the following command:
git clone -o youruserid https://your-fork-URL
Navigate to the newly created directory by using
Finally, include the original project as a remote by running the following, replacing
ownerID with the original project owner's GitHub ID, and the URL with the original project's
.git URL. You can obtain the original project's
.git URL by clicking the green Code button on the original project's GitHub repository, and copying the URL.
git remote add ownerID https://original-project-url
Now you're entirely up to date again and ready to begin working with the code!
For details on the next steps, check out the rest of this guide.