Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can work directly on the master branch or you can create a branch with the following commands:Create a separate branch for your work, this will facilitate creating patches and re-synchronizing with upstream.

Code Block
languagebash
linenumberstrue
git checkout master # If not already in master.
git checkout -b <branch_name> # Create and switch to the branch.

...

Same as the clone workflow, you can work directly on your fork's master branch or create a new separate branch for your work.

Code Block
languagebash
linenumberstrue
git checkout master #  If not already in master.
git checkout -b <branch_name> # Create and switch to the branch.
git push -u origin <branch_name> # Push the newly created branch to the fork and set it to track the remote branch.

...

Generating a Patch from a Clone

In what follows we're going to assume that the remote alias is origin and that you have a local master branch tracking the remote master branch.
Note, that this happens automatically when you clone a repository.

REVISIT: If someone uses clone with options like -o, we're going to assume he/she knows how to adapt what's below.

Before starting your work, make sure that you have the latest changes: git pull origin master this will fetch and integrates the remote changes to your local clone.

When you are done developing and you are satisfied with your work, you can create a patch using this GIT command:

git format-patch -<n> <sha>

When you are done developing and you are satisfied with your work, you can create a patch using this GIT command:

git format-patch -<n> <sha>

This will create a patch set based on the last number of commits <n> starting at the commit <sha>.  This will create a patch set based on the last number of commits <n> starting at the commit <sha>.  Or

git format-patch -<n> HEAD

...

Getting to this point your patch has been accepted and pushed to the main repository. Thank you for your contribution.
Now, you need to re-synch synchronize your local clone. It's important to note that committers can perform some minor changes on your behalf, so always pull the latest changes.
If you were working on a branch, just delete the branch and pull master. You can do this with the following GIT commands.

...

If you were working on master, reset the HEAD back to where origin was and pull master.

REVISIT: Anything better than the cruel reset --hard?

Code Block
Code Block
languagebash
linenumberstrue
git reset --hard origin/master # Reset back to origin.

git pull origin master # Fetch the latest changes from remote and merge them to your local repository.

...

  • Make your your changes on a branch (or even on master) and commit the change to your local clone of the fork using git commit
  • Push your changed code to your private fork:  git push origin <branch> where <branch> <branch_name> where <branch_name> may be master.
  • Then visit your fork at http://github.com/<username>/incubator-nuttx
  • To the right of the Branch menu, click New pull request and follow the instructions.

...

After your Pull-Request has been accepted, you will need to synchronize your fork with the upstream.   Instructions for doing this are available here: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork.  This will differ slightly depending on whether you were working on a branch or on master.

If working on a separate branch, follow these GIT commands:

Code Block
languagebash
linenumberstrue
git checkout master              # Switch to master branch
git branch -D <branch_name>      # Delete the local branch
git push -d origin <branch_name> # Delete the remote branch
git fetch upstream               # Get latest changes from upstream
git merge upstream/master        # Merge changes with the local master
git push origin master           # Synchronize the private fork

If working on master:

Code Block
languagebash
linenumberstrue
git reset --hard upstream/master # Reset back to upstream.
git fetch upstream               # Get latest changes from upstream
git merge upstream/master        # Merge changes with local master
git push origin master           # Synchronize the private fork

Often, a fork will diverge too much from the upstream repository to keep in synchronization properly.  In this case, feel free to create a new private fork, removing the old forked repository first, of course.
It is a common practice to delete a fork after the pull-request has been closed.  GitHub even supports a special shortcut to delete your fork.  After the your PR has been closed, go to the https://github.com/apache/incubator-nuttx/pull/NN page (where NN is the PR number that was assigned to your pull request).  You will see this message on that page:

...