Skip to main content

Contributing to projects

Learn how to contribute to a project through forking.

About forking

If you want to contribute to someone else's project but don't have write access to the repository, you can use a "fork and pull request" workflow.

Una bifurcación es un nuevo repositorio que comparte la configuración de visibilidad y código con el repositorio “ascendente” original. Las bifurcaciones se suelen usar para iterar ideas o cambios antes de que se vuelvan a proponer al repositorio ascendente, como en proyectos de código abierto o cuando un usuario no tiene acceso de escritura al repositorio ascendente.

You can contribute by submitting pull requests from your fork to the upstream repository. For more information, see "Fork a repo."

Forking a repository

This tutorial uses the Spoon-Knife project, a test repository that's hosted on that lets you test the fork and pull request workflow.

  1. Navigate to the Spoon-Knife project at
  2. Click Fork. Fork button
  3. Select an owner for the forked repository. Create a new fork page with owner dropdown emphasized
  4. By default, forks are named the same as their upstream repositories. You can change the name of the fork to distinguish it further. Create a new fork page with repository name field emphasized
  5. Optionally, add a description of your fork. Create a new fork page with description field emphasized
  6. Choose whether to copy only the default branch or all branches to the new fork. For many forking scenarios, such as contributing to open-source projects, you only need to copy the default branch. By default, only the default branch is copied. Option to copy only the default branch
  7. Click Create fork. Emphasized create fork button

Note: If you want to copy additional branches from the upstream repository, you can do so from the Branches page. For more information, see "Creating and deleting branches within your repository."

Cloning a fork

You've successfully forked the Spoon-Knife repository, but so far, it only exists on GitHub. To be able to work on the project, you will need to clone it to your computer.

You can clone your fork with the command line, GitHub CLI, or GitHub Desktop.

  1. On GitHub, navigate to your fork of the Spoon-Knife repository.

  2. Encima de la lista de archivos, haga clic en Código. Botón "Código"

  3. Copia la dirección URL del repositorio.

    • Para clonar el repositorio con HTTPS, en «HTTPS» haz clic en .
    • Para clonar el repositorio mediante una clave SSH, incluido un certificado emitido por la entidad de certificación SSH de la organización, haga clic en Usar SSH y luego en .
    • Para clonar un repositorio mediante GitHub CLI, haz clic en GitHub CLI y, después, haz clic en . El icono del portapapeles para copiar la URL para clonar un repositorio con el CLI de GitHub
  4. Abra TerminalTerminalGit Bash.

  5. Cambia el directorio de trabajo actual a la ubicación en donde quieres clonar el directorio.

  6. Type git clone, and then paste the URL you copied earlier. It will look like this, with your GitHub username instead of YOUR-USERNAME:

    $ git clone
  7. Press Enter. Your local clone will be created.

    $ git clone
    > Cloning into `Spoon-Knife`...
    > remote: Counting objects: 10, done.
    > remote: Compressing objects: 100% (8/8), done.
    > remove: Total 10 (delta 1), reused 10 (delta 1)
    > Unpacking objects: 100% (10/10), done.

Para obtener más información sobre GitHub CLI, vea "Acerca de GitHub CLI".

To create a clone of your fork, use the --clone flag.

gh repo fork REPOSITORY --clone=true
  1. En el menú File, haga clic en Clone Repository.

    Clonar opción de menú en la aplicación Mac

    Opción Clone menu (Clonar menú) en la app de Windows

  2. Haz clic en la pestaña que corresponde a la ubicación del repositorio que deseas clonar. También puede hacer clic en URL para especificar manualmente la ubicación del repositorio.

    Pestañas de ubicación en el menú Clone a repository (Clonar un repositorio)

    Pestañas de ubicación en el menú Clone a repository (Clonar un repositorio)

  3. Elija el repositorio que quiera clonar en la lista.

    Clonar una lista de repositorio

    Clonar una lista de repositorio

  4. Haga clic en Elegir... y navegue hasta una ruta local donde quiera clonar el repositorio.

    El botón Elegir

    El botón Elegir

  5. Haga clic en Clone (Clonar).

    El botón Clonar

    El botón Clonar

Creating a branch to work on

Before making changes to the project, you should create a new branch and check it out. By keeping changes in their own branch, you follow GitHub Flow and ensure that it will be easier to contribute to the same project again in the future. For more information, see "GitHub Flow."

git branch BRANCH-NAME
git checkout BRANCH-NAME
git branch BRANCH-NAME
git checkout BRANCH-NAME

For more information about how to create and manage branches in GitHub Desktop, see "Managing branches."

Making and pushing changes

Go ahead and make a few changes to the project using your favorite text editor, like Visual Studio Code. You could, for example, change the text in index.html to add your GitHub username.

When you're ready to submit your changes, stage and commit your changes. git add . tells Git that you want to include all of your changes in the next commit. git commit takes a snapshot of those changes.

git add .
git commit -m "a short description of the change"
git add .
git commit -m "a short description of the change"

For more information about how to stage and commit changes in GitHub Desktop, see "Committing and reviewing changes to your project."

When you stage and commit files, you essentially tell Git, "Okay, take a snapshot of my changes!" You can continue to make more changes, and take more commit snapshots.

Right now, your changes only exist locally. When you're ready to push your changes up to GitHub, push your changes to the remote.

git push
git push

For more information about how to push changes in GitHub Desktop, see "Pushing changes to GitHub."

Making a pull request

At last, you're ready to propose changes into the main project! This is the final step in producing a fork of someone else's project, and arguably the most important. If you've made a change that you feel would benefit the community as a whole, you should definitely consider contributing back.

To do so, head on over to the repository on GitHub where your project lives. For this example, it would be at<your_username>/Spoon-Knife. You'll see a banner indicating that your branch is one commit ahead of octocat:main. Click Contribute and then Open a pull request.

GitHub will bring you to a page that shows the differences between your fork and the octocat/Spoon-Knife repository. Click Create pull request.

GitHub will bring you to a page where you can enter a title and a description of your changes. It's important to provide as much useful information and a rationale for why you're making this pull request in the first place. The project owner needs to be able to determine whether your change is as useful to everyone as you think it is. Finally, click Create pull request.

Managing feedback

Pull Requests are an area for discussion. In this case, the Octocat is very busy, and probably won't merge your changes. For other projects, don't be offended if the project owner rejects your pull request, or asks for more information on why it's been made. It may even be that the project owner chooses not to merge your pull request, and that's totally okay. Your changes exist in your fork. And who knows--maybe someone you've never met will find your changes much more valuable than the original project.

Finding projects

You've successfully forked and contributed back to a repository. Go forth, and contribute some more! For more information, see "Finding ways to contribute to open source on GitHub."