Skip to content

Working with GitHub

Nikhil Nanivadekar edited this page Aug 16, 2020 · 8 revisions
Eclipse COllections Logo

First time setup

  1. Fork from the main project. We use the master branch in this example.
    Link: https://github.com/eclipse/eclipse-collections

  2. Copy this forked repository’s link. Usually, this contains your account name.
    Example: https://github.com/<username>/eclipse-collections.git

  3. Create a local clone of this fork. By default git will create a remote named origin+ cd <working directory>
    git clone <link from step 2>
    cd eclipse-collections

  4. Configure upstream remote
    git remote add upstream https://github.com/eclipse/eclipse-collections.git

  5. Fetch contents from remote
    git fetch --all

Working on a pull request

Note: git is quite flexible and there are many ways to do this work. The following is a very condensed, simplified outline. For example, it’s prudent to use a branch for working on a sizable code change, which is not discussed below.

  1. Syncing fork
    git fetch --all
    git pull upstream master --rebase

  2. Add (or remove) the changes to git (see git add or git rm help online)

  3. Commit and push changes to fork
    git commit --message "My commit message as per guidelines" --signoff
    git push

    1. Link to commit message guidelines.

    2. If a Github issue exists that this PR is fixing, add "Fixes #<issue>" or "Resolves #<issue>" at the end of the commit message, or on a new line. You don’t have to create a new issue just to close it with a PR. A PR is an issue (they share a namespace / sequence number).

  4. When you’re ready for the pull request,

    1. Sync your fork (See step 1)

    2. git push

  5. Create a Pull request via the Github UI.

  6. Pull requests may result in review comments or build failures.

  7. Make necessary code changes to address the review feedback.

  8. Repeat steps 6 and 7 to add, commit and push changes.

  9. If you have more than one commit, squash multiple commits into one and then push them using interactive rebase
    git rebase -i upstream/master

  10. The interactive rebase is a mechanism to squash all individual commits of the fork to one single commit.

    1. You should see a list of commits, each commit starting with the word "pick".

    2. Ensure the first commit says "pick" and change the rest from "pick" to "squash". — This will squash each commit into the previous commit, which will continue until every commit is squashed into the first commit.

    3. Save and close the editor.

    4. You will get an opportunity to change the commit message

    5. Save and close the editor again.

    6. Force push the final, squashed commit
      git push -f

  11. Pull request is automatically updated with the recent changes.

  12. Rinse and repeat until pull request is approved and merged.