2021 Update
@VonC's answer is conceptually correct and still the one supported by GitHub. After nine years, @Sebi finally gets the answer he wanted -- I eliminated the "indirection" he commented on that occurs in the second bullet of VonC's answer.
For my use case, I need to make both public and private changes to a public repo. Public commits can be pushed periodically as soon as they are ready. Private changes must remain in my private repo until I complete my PhD research. At that time, I'll need all private changes to flow from my public fork to the original public repo via pull requests.
The bulk of the work is getting things set up correctly. I provided detailed steps in this SO answer. The following steps are done exclusively in the eclipse GUI (v2020-12; EGit 5.11), but can easily be translated to command line operations. The repositories I used are these:
eclipse/org.aspectj
is the original public repo; the upstream
remote for fetching
cb4/org.aspectj
is my fork; the origin
remote for pushing
cb4/remPrivAJ
is my remote private repo; the private
remote for pushing and pulling
I:\local
is the local repo on my workstation
For github authentication, I used ssh with an ed25519 ssh key (how-to in this SO question) so my connection URIs look like this: ssh://git@github.com/<user>/<repo>
.
Notation: ->
is a mouse click or selection; right->
and double->
are right-click and double-click, respectively.
I separated public from private changes by putting each in separate branches: pub
for public changes; priv
for private changes. I'm fairly new to git, so there may be a better way to do this.
- Create and configure branches
- 1.1 In the eclipse Git Perspective, under the local repo: open
Branches
then open Local
(-> v
beside each)
- 1.2 For the private branch:
right-> master -> Create Branch -> Select -> private/master -> Ok
enter priv for Branch name: -> Configure upstream for push and pull -> When pulling: Merge -> Finish
- 1.3 For the public branch:
right-> master -> Create Branch
enter pub for Branch name: -> Finish
- 1.4 The result: commit numbers in my private repo
private/master
, my public fork orign/master
, and the original public repo upstream/master
all match

- Make a private change and commit
- 2.1 Make some changes, then see detailed info about them on the
Git Staging
tab in the Git Perspective
- 2.2 Select individual changes and add them to the index by clicking the green plus sign
- 2.3 OR select them all by clicking green double plus sign
- 2.4. Enter a commit message and
-> Commit and Push -> Preview -> Push -> Close
- 2.5 Note the new commit number

- Push private changes to the public fork
right-> priv -> Push Branch -> Remote: dropdown v -> origin: URI
(mine is origin:ssh://git@github.com/cb4/org.aspectj) double-> master
in the Branch: text box and type priv
then double-> priv [branch] -> Preview -> Push -> Close
- On GitHub, private changes in my public fork. Note same commit number here as above (click image to zoom).

- To complete the process and open a pull request for a private change against the original public repo, just click on
Compare & pull request
and Voila! (click image to zoom).

Additional Features and Functions
- Of course, you can push public commits to the public fork:
right-> pub -> Push Branch -> Preview -> Push -> Close
- Pull and merge updates from the original public repo as frequently as it changes to reduce merge conflicts: under Remotes
right-> upstream -> Fetch
- Then push them to your fork: under Remotes
right-> origin -> Push
- And to your private repo: under Remotes
right-> private -> Push