-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Git cheat sheet
This page is meant as a handy reference for some basic Git commands.
- Add a remote to link your local copy of the repository (cloned from your fork) to the main Oppia repository. Required for all the 'upstream' based commands below.
$ git remote add upstream https://github.com/oppia/oppia.git
- After making a local clone of Oppia, you can change code in your local
oppia/
directory. Git will track these changes. At any time, you can check what git thinks has been changed using:
$ git status
You can also view diffs of your changes by typing:
$ git diff
- To sync your local code with the latest updates from the GitHub repo, run:
$ git fetch upstream
$ git merge upstream/develop
- To download a branch someone else created:
$ git checkout -b {{branch-name}}
$ git pull https://github.com/{{their-repo-name}}/oppia.git {{branch-name}}
- To create a patch:
$ git checkout {{branch-to-patch-from}}
$ git format-patch -1 # goes back one commit
This should create a file with the extension .patch. The name should include part of the commit message from the change it is patching. You may need to move this file outside oppia/
so that it won't disappear when you switch branches.
- To apply a patch:
$ git checkout {{branch-to-patch-to}}
$ git apply {{patch-file-name}}
- To squash the last three commits into a single one:
git reset --soft HEAD~3 &&
git commit -m "{{YOUR_COMMIT_MESSAGE_HERE}}"
Be careful to only squash "local" commits -- never squash anything that has been uploaded to the codesite before (no matter what branch). In particular, don't squash commits that already have code review comments on them. Also, don't squash any commit that merged two branches.
If you want to squash commits that you previously pushed to GitHub, make a new local branch that includes the small commits, squash the commits locally, and push the new branch instead.
Have an idea for how to improve the wiki? Please help make our documentation better by following our instructions for contributing to the wiki.
Core documentation
Developing Oppia
- FAQs
- Installing Oppia
- Getting started with the codebase
- Making your first PR
- Learning resources for developers
- Codebase Overview
- Coding Guidelines
- Coding style guide
- Guidelines for creating new files
- How to add a new page
- How to write frontend type definitions
- How to write design docs
- Revert and Regression Policy
- Server errors and solutions
-
Debugging
- If your presubmit checks fail
- If CI checks fail on your PR
- Finding the commit that introduced a bug
- Interpreting GitHub Actions Results
- Debugging Docs
- Debugging datastore locally
- Debugging end-to-end tests
- Debugging backend tests
- Debugging frontend tests
- Debug frontend code
- Debugging custom ESLint check tests
- Debugging custom Pylint check tests
- Debugging Stories
- Guidelines for launching new features
- Guidelines for making an urgent fix (hotfix)
- Lint Checks
- Oppia's code owners and checks to be carried out by developers
- Privacy aware programming
- Backend Type Annotations
- Bytes and string handling in Python 3
- Guidelines for Developers with Write Access to oppia/oppia
- Testing
- Release Process
Developer Reference
- Oppiabot
- Frontend
- Backend
- Translations
- Webpack
- Third-party libraries
- Extension frameworks
- Oppia-ml Extension
- Mobile development
- Mobile device testing
- Performance testing
- Build process
- Team structure
- Triaging Process
- Playbooks
- Wiki
- Past Events