Skip to content
Ahmad Ammar

4. Make the change

The examples below use a made-up project called their-project. Its README says CVS where it means CSV. The text printed under each command came from really running that command, with the addresses replaced by sample ones.

4.1 Fork the project

On the project’s GitHub page, press Fork near the top right, then press Create fork on the page that follows. You now have your own copy at github.com/your-name/their-project. It is yours, so you can do anything to it without affecting the original.

4.2 Download your copy

On your fork’s page, press the green Code button and copy the HTTPS address. Then, in a VS Code terminal, clone it, using your own address:

$ git clone https://github.com/your-name/their-project.git
Cloning into 'their-project'...
done.

Move into the folder and open it:

cd their-project
code .

4.3 Tell Git about the original project

Your computer knows about your fork, which Git calls origin. It also needs to know about the original, which by custom is called upstream, so that you can collect new work from it later. Use the original project’s address here:

$ git remote add upstream https://github.com/their-name/their-project.git
$ git remote -v
origin  https://github.com/your-name/their-project.git (fetch)
origin  https://github.com/your-name/their-project.git (push)
upstream    https://github.com/their-name/their-project.git (fetch)
upstream    https://github.com/their-name/their-project.git (push)

4.4 Make a branch

Never work directly on main. A branch keeps this one change apart, so you can run several proposals at once and keep main matching the original. Give it a name that says what it does:

$ git switch -c fix-readme-spelling
Switched to a new branch 'fix-readme-spelling'

4.5 Change the file and check it

Open the file in VS Code, change it and save it. Then ask Git to show you exactly what is different. Lines starting with - were removed and lines starting with + were added. Check that nothing else has changed by accident, such as stray spaces.

$ git diff
diff --git a/README.md b/README.md
index 1a2b3c4..5d6e7f8 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,3 @@
 # Their project

-This tool reads a CVS file.
+This tool reads a CSV file.

If you changed code, run the project’s tests. CONTRIBUTING.md or the README normally says how. Many Python projects use the commands below, where the first makes an isolated workspace, the second installs the project into it, and the third runs its tests:

python -m venv .venv
.venv\Scripts\activate
pip install -e .
pip install pytest
pytest

The second line is for Windows. On a Mac or on Linux, it is source .venv/bin/activate.

If you fixed a mistake in code, add a test too, as maintainers look for one. A test is a small piece of code that checks a known answer, and it fails if someone breaks that behaviour later. Here is one for a function that works out the area of a circle:

from areas import circle_area

def test_circle_area_of_radius_two():
    assert abs(circle_area(2) - 12.566) < 0.01

4.6 Save a version

Choose only the files you meant to change, then write a note that says what the change does:

$ git add README.md
$ git commit -m "Fix spelling of CSV in the README"
[fix-readme-spelling 1b1be51] Fix spelling of CSV in the README
 1 file changed, 1 insertion(+), 1 deletion(-)

4.7 Send it to your fork

$ git push -u origin fix-readme-spelling
branch 'fix-readme-spelling' set up to track 'origin/fix-readme-spelling'.
To https://github.com/your-name/their-project.git
 * [new branch]      fix-readme-spelling -> fix-readme-spelling

Git prints an address for opening a pull request, which you can use in the next chapter.