User Tools

Site Tools


docs:guide-developer:working-with-github-pr

Working with GitHub

There are GitHub mirrors of the source repository here.

Fork the project to a public repo using GitHub web interface, clone the repo to your computer, create a branch for your changes, push these back to GitHub and submit a pull request.

In case you don't know how to do that, keep reading.

Create a GitHub account, this will host your public fork of OpenWrt source, and will be used for all interaction on GitHub.

Install git in your PC, and make sure that your local git settings have the right name and email:

git config --global user.name "my name"
git config --global user.email "my@email.address"

You might also want to set the default text editor to your favorite editor. If you have a Linux system with a GUI, some choices are geany, kwrite, pluma and gedit. If you are using command line, nano is a good one.

git config --global core.editor "editor-name-here"

Then follow GitHub's excellent documentation to Fork A Repo and Create a local clone of your fork.

After you have set it up as described, write

git checkout -b my-new-branch-name

to create a branch for your PR (“my-new-branch-name” is just an example name, use a more descriptive name in yours).

All commits you do after this command will be grouped in this branch. This allows to have multiple branches, one for each PR. To switch between branches you already created, use

git checkout my-branch-name

After you made your changes, write

git add -i

and use its interface to add untracked (new) files and update existing ones.

Then write

git commit --signoff

This will open the git default editor and you can write the commit message.

The first line is the commit subject, then leave an empty line, then you write the commit description. This command will automatically add the Signed-off-by line with your name and email as set above. For example, a complete commit message might look like this:

The best code update.
 
This is the best piece of code I have ever submitted.
Signed-off-by: John Doe <John.Doe@test.com>

To send your local changes over to your GitHub repo, write

git push --all

You will be asked your GitHub user and password in the process.

After the code has been uploaded to your GitHub repo, you can submit PR using GitHub web interface, see again GitHub's documentation about Creating a pull request.

Squashing commits

Commits in a PR or sent by email should be about full changes you want to merge, not about fixing all issues the reviewers found in your original PR.

So, there will come a time when you will need to either rewrite or squash your commits; so you end with a normal amount of true and sane commits.

Work with git commandline. Change to your development folder. Look at the branches you have with:

git branch -a

get something like:

  best_code_update
* master

Switch to the your development branch for this PR with:

git checkout best_code_update

Look at the git log, so you can count the number of commits you want to squash ( the “X” below ) with:

git log

Delete commits with:

git reset HEAD~X

(where X is the number of commits you want to delete, counted from the last commit), this will not change modified files, it will only delete the commits.

Add the files to git tracking again with:

git add -i

and commit again with:

git commit --signoff

Send the updated branch over to GitHub with:

git push -f

and the commits in the PR will be updated automatically.

Alternative squashing advice

You can use interactive rebase to combine, reorder and edit your commits and their commit messages, with:

git rebase -i HEAD~X

Where X is a number of commits to edit.

docs/guide-developer/working-with-github-pr.txt · Last modified: 2019/04/06 02:48 by vgaetera