DEV Community

Cover image for How to commits to open source in GitHub. Step-by-step guide
Maxim Dzyubak
Maxim Dzyubak

Posted on

How to commits to open source in GitHub. Step-by-step guide

The guides are written for the github service. You need to log in to your account or sign up.

All commands in these guides are entered in the terminal.

  1. Make a fork (copy) of the desired project. Go to your account and go to the just created fork.

  2. Clone the fork (copy) of the project from step 1 to your computer.
    Example:
    git clone git@github.com:maxdzyubak/vite.git

  3. Configure the git config locally (local). It must be repeated for each project:
    git config --local user.name maxdzyubak
    git config --local user.email maxdzyubak@gmail.com
    Or global. Set up once for all projects
    git config --global user.name maxdzyubak
    git config --global user.email maxdzyubak@gmail.com

  4. We make a pointer to the original upstream repository from which we made the fork. This is needed to download the latest code updates from the original repository. (Checking upstream: git remote -v).
    Example:
    git remote add upstream https://github.com/vitejs/vite.git

  5. Create a new branch and go straight to it. Make all changes there. This is considered good practice
    git switch -c new_branch

  6. You can check the status of changes made with the command
    git status

  7. Add the changes to staged. Git starts tracking changes to the file(s)
    git add README.md

  8. Make a commit with the changes. If there is an issue number, the best way to commit is to write it like this: [#123] fix bug. If you just put a grid without parentheses, it will ignore it in the git rebase
    git commit -m 'Update README.md'

  9. Check the commit made
    git log

  10. Push the changes made to the outside world, because for now they are only on our local computer, indicating the created branch
    git push origin new_branch

  11. Create a pull request by clicking on the green button labeled Compare & pull request either in the original repository from which you made the fork, or locally in our github account.


Docs:
git-clone - Clone a repository into a new directory
Customizing Git - Git Configuration
git-remote - Manage set of tracked repositories
Git Branching - Basic Branching and Merging
git-status - Show the working tree status
git-add - Add file contents to the index
git-commit - Record changes to the repository
git-log - Show commit logs
git-push - Update remote refs along with associated objects
git-request-pull - Generates a summary of pending changes

Top comments (0)