Some hints on using GitHub for the PNG specification. Part three, multiple pull requests!

It would be bad if we had to wait for one pull request to be all 
finished, everyone is agreed and it gets merged, before starting work on 
a different, unrelated change.

But equally, we don't want the changes we made for one thing to get all 
mixed up with different changes for something else. The way to avoid 
that is:

 1. Make sure the main branch is always up to date before you start work
 2. Make a new branch for each different thing.


    Starting from a clean slate

First we need to get off whatever branch we were on, and back to the 
*main *one.

git checkout main

Switched to branch 'main'
Your branch is behind 'origin/main' by 1 commit, and can be fast-forwarded.
   (use "git pull" to update your local branch)

Notice that we didn't use the -b option here, which is only for creating 
a /new /branch. Now we pull in whatever other changes have been made to 
the main branch since we were last here:

git pull --rebase

Updating 46f1ef3..c1596fb
Fast-forward
  index.html | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
Current branch main is up to date.

Always do this. We haven't discussed the ugly reality of resolving merge 
conflicts yet, and if we always create new branches from a fully 
up-to-date main we can keep it that way.


    New branch for a new pull request

Suppose we want to suggest a better definition for the term "luminance". 
Off we go:

git checkout -b define-luminance

Git confirms what we just did:

Switched to a new branch 'define-luminance'

Now we make our edits. Remember in part one where we changed colour to 
color? You may notice while editing that all those changes have/gone 
away/ and it says colour everywhere again. That is okay! The changes we 
made earlier are safely stored in that other branch, so they don't get 
in the way of what we are doing here. Save your edits, and commit them.

git add index.html
git commit -m "better but still short luminance definition, fixes #406"

Git confirms that this worked:

[define-luminance ff7d914] better but still short luminance definition, 
fixes #406
  1 file changed, 1 insertion(+), 1 deletion(-)

Now we can push. Same as before, letting git tell you off is the easiest 
way:

git push

fatal: The current branch define-luminance has no upstream branch.
To push the current branch and set the remote as upstream, use

     git push --set-upstream origin define-luminance

Thanks for the reminder, git.

git push --set-upstream origin define-luminance

Git gives us the same chatty commentary on what it is doing:

Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 20 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 458 bytes | 30.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote:
remote: Create a pull request for 'define-luminance' on GitHub by visiting:
remote: https://github.com/w3c/PNG-spec/pull/new/define-luminance
remote:
To github.com:w3c/PNG-spec.git
  * [new branch]      define-luminance -> define-luminance
Branch 'define-luminance' set up to track remote branch 
'define-luminance' from 'origin'.

Now we can go to that web page to create the pull request, same as we 
saw in part one.

-- 
Chris Lilley
@svgeesus
Technical Director @ W3C
W3C Strategy Team, Core Web Design
W3C Architecture & Technology Team, Core Web & Media

Received on Saturday, 13 January 2024 13:54:14 UTC