Skip to content

Instantly share code, notes, and snippets.

@devinschumacher
Last active October 27, 2025 17:07
Show Gist options
  • Save devinschumacher/c0d45bc626999f19df5429c5cd549a8c to your computer and use it in GitHub Desktop.
Save devinschumacher/c0d45bc626999f19df5429c5cd549a8c to your computer and use it in GitHub Desktop.

Revisions

  1. devinschumacher revised this gist May 15, 2025. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion private-github-forks.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,9 @@ tags:

    ## Click here to watch the video 👇

    <a href="https://www.youtube.com/watch?v=uSKVQxOEark" target="_blank"><img src="https://i.ibb.co/6q8PFp5/7dad0a8df535.jpg" width="600px"></a>
    <a href="https://www.youtube.com/watch?v=uSKVQxOEark" target="_blank"><img src="https://gist.github.com/user-attachments/assets/68b409e3-8376-4c13-9fa9-8e677e7bdc1f" width="600px"></a>




    ---
  2. devinschumacher revised this gist May 15, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion private-github-forks.md
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ tags:
    4. [Re-assign remotes](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#4-re-assign-remotes)
    5. [Push branches to your private repo](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#5-push-branches-to-your-private-repo)
    6. [(optional) check the it worked](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#6-optional-check-the-it-worked)
    7.[ Get to work](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#7-get-to-work)
    7. [Get to work](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#7-get-to-work)



  3. devinschumacher revised this gist May 15, 2025. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion private-github-forks.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,8 @@ tags:

    ## Click here to watch the video 👇

    <a href="https://www.youtube.com/watch?v=uSKVQxOEark" target="_blank"><img src="https://img.youtube.com/vi/uSKVQxOEark/maxresdefault.jpg" width="600px"></a>
    <a href="https://www.youtube.com/watch?v=uSKVQxOEark" target="_blank"><img src="https://i.ibb.co/6q8PFp5/7dad0a8df535.jpg" width="600px"></a>


    ---

  4. devinschumacher renamed this gist May 2, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. devinschumacher revised this gist Apr 29, 2025. 1 changed file with 11 additions and 18 deletions.
    29 changes: 11 additions & 18 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -107,33 +107,26 @@ git remote set-url --push upstream no_push
    Then run `git remove -v` again, and you should the push remove


    However:

    ⚠️ GitHub pull requests are not tied to git push remotes.
    ⚠️ However: GitHub pull requests are not tied to git push remotes.

    When you push to your origin (your fork), GitHub sees:
    • Your fork has new commits
    • Your fork was originally based on the place you forked from
    • GitHub suggests a PR back to upstream (since it knows the relationship)

    This happens even if you:
    • Only pushed to origin
    • Have disabled push to upstream

    - Your fork has new commits
    - Your fork was originally based on the place you forked from
    - GitHub suggests a PR back to upstream (since it knows the relationship)

    ✅ To be even safer, remove Github from offering PRs back to upstream:

    👉 Detach the fork on GitHub:
    1. Go to your fork: https://github.com/your-org/your-repo
    2. Click Settings
    3. Scroll to “Danger Zone”
    4. Click “Detach fork” → Confirm
    1. Go to your fork: https://github.com/your-org/your-repo
    2. Click Settings
    3. Scroll to “Danger Zone”
    4. Click “Detach fork” → Confirm

    This will:
    Break GitHub’s fork link
    Make GitHub stop suggesting PRs back to serpcompany/serp-monorepo
    • But keep your repo and remotes intact — you can still git fetch upstream from CLI
    - Break GitHub’s fork link
    - Make GitHub stop suggesting PRs back to the original place you forked from
    - Keep your repo and remotes intact — you can still git fetch upstream from CLI



  6. devinschumacher revised this gist Apr 29, 2025. 1 changed file with 32 additions and 3 deletions.
    35 changes: 32 additions & 3 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -95,18 +95,47 @@ git remote show upstream
    git switch main
    ```

    ## (optional) BUT VERY SAFE
    ## (optional) BUT VERY SAFE

    ### 1. Remove `push` ability to the upstream

    You can REMOVE the ability to push your now private (and probably NSWF filled) repo by running
    ```bash
    git remote set-url --push upstream no_push
    ```

    Then run `git remove -v` again, and you should see safety
    Then run `git remove -v` again, and you should the push remove


    However:

    ⚠️ GitHub pull requests are not tied to git push remotes.

    When you push to your origin (your fork), GitHub sees:
    • Your fork has new commits
    • Your fork was originally based on the place you forked from
    • GitHub suggests a PR back to upstream (since it knows the relationship)

    This happens even if you:
    • Only pushed to origin
    • Have disabled push to upstream


    ✅ To be even safer, remove Github from offering PRs back to upstream:

    👉 Detach the fork on GitHub:
    1. Go to your fork: https://github.com/your-org/your-repo
    2. Click Settings
    3. Scroll to “Danger Zone”
    4. Click “Detach fork” → Confirm

    This will:
    • Break GitHub’s fork link
    • Make GitHub stop suggesting PRs back to serpcompany/serp-monorepo
    • But keep your repo and remotes intact — you can still git fetch upstream from CLI


    git remote set-url --push upstream no_push

    ---

  7. devinschumacher revised this gist Apr 29, 2025. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -95,6 +95,19 @@ git remote show upstream
    git switch main
    ```

    ## (optional) BUT VERY SAFE

    You can REMOVE the ability to push your now private (and probably NSWF filled) repo by running
    ```bash
    git remote set-url --push upstream no_push
    ```

    Then run `git remove -v` again, and you should see safety



    git remote set-url --push upstream no_push

    ---

    # Example
  8. devinschumacher revised this gist Apr 28, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -11,12 +11,12 @@ tags:
    # How to Create a Private “Fork” of a Public GitHub Repo | Step-by-step Guide

    1. [Clone the original repository locally](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#1-clone-the-original-repository-locally)
    2. Create an empty private repo in your org
    2. [Create an empty private repo in your org](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#2-create-an-empty-private-repo-in-your-org)
    3. [Create a local “fork” branch](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#3-create-a-local-fork-branch)
    4. [Re-assign remotes](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#4-re-assign-remotes)
    5. [Push branches to your private repo](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#5-push-branches-to-your-private-repo)
    6. [(optional) check the it worked](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#6-optional-check-the-it-worked)
    7. Get to work
    7.[ Get to work](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#7-get-to-work)



  9. devinschumacher revised this gist Apr 28, 2025. 1 changed file with 17 additions and 6 deletions.
    23 changes: 17 additions & 6 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,17 @@ tags:
    - cli
    ---

    # How to Create a Private “Fork” of a Public GitHub Repo
    # How to Create a Private “Fork” of a Public GitHub Repo | Step-by-step Guide

    1. [Clone the original repository locally](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#1-clone-the-original-repository-locally)
    2. Create an empty private repo in your org
    3. [Create a local “fork” branch](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#3-create-a-local-fork-branch)
    4. [Re-assign remotes](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#4-re-assign-remotes)
    5. [Push branches to your private repo](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#5-push-branches-to-your-private-repo)
    6. [(optional) check the it worked](https://gist.github.com/devinschumacher/c0d45bc626999f19df5429c5cd549a8c/edit#6-optional-check-the-it-worked)
    7. Get to work



    ## Click here to watch the video 👇

    @@ -73,15 +83,16 @@ git push -u origin main
    git push -u origin fork
    ```

    ## 6. Get to work
    ## 6. (optional) check the it worked:
    ```bash
    git switch main
    git remote show origin
    git remote show upstream
    ```

    ## (optional) check the it worked:

    ## 7. Get to work
    ```bash
    git remote show origin
    git remote show upstream
    git switch main
    ```

    ---
  10. devinschumacher revised this gist Apr 27, 2025. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,12 @@ tags:

    # How to Create a Private “Fork” of a Public GitHub Repo

    ## Click here to watch the video 👇

    <a href="https://www.youtube.com/watch?v=uSKVQxOEark" target="_blank"><img src="https://img.youtube.com/vi/uSKVQxOEark/maxresdefault.jpg" width="600px"></a>

    ---

    ## 1. Clone the original repository locally

    ```bash
  11. devinschumacher revised this gist Apr 27, 2025. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -25,12 +25,7 @@ mv <REPO_NAME> <NEW_NAME>
    cd <REPO_NAME> <NEW_NAME>
    ```

    ## 2. Create a local “fork” branch
    ```bash
    git checkout -b fork
    ```

    ## 3. Create an empty private repo in your org
    ## 2. Create an empty private repo in your org
    ```bash
    gh api \
    --method POST \
    @@ -40,6 +35,12 @@ gh api \
    -f auto_init=false
    ```


    ## 3. Create a local “fork” branch
    ```bash
    git checkout -b fork
    ```

    ## 4. Re-assign remotes
    Rename the existing `origin` (public repo) to `upstream` and add your private repo as `origin`:

  12. devinschumacher revised this gist Apr 27, 2025. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -32,10 +32,12 @@ git checkout -b fork

    ## 3. Create an empty private repo in your org
    ```bash
    gh repo create :<YOUR_ORG>/<NEW_REPO_NAME> \
    --private \
    --no-readme \
    --confirm
    gh api \
    --method POST \
    /orgs/<YOUR_ORG>/repos \
    -f name='<NEW_REPO_NAME>' \
    -f private=true \
    -f auto_init=false
    ```

    ## 4. Re-assign remotes
  13. devinschumacher revised this gist Apr 27, 2025. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion post.md
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,12 @@ git checkout -b fork
    ```

    ## 3. Create an empty private repo in your org
    - Github.com → New → Repository (Do not initialize with a README, license, or .gitignore. + leave Initialize this repository unchecked)
    ```bash
    gh repo create :<YOUR_ORG>/<NEW_REPO_NAME> \
    --private \
    --no-readme \
    --confirm
    ```

    ## 4. Re-assign remotes
    Rename the existing `origin` (public repo) to `upstream` and add your private repo as `origin`:
  14. devinschumacher revised this gist Apr 27, 2025. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion post.md
    Original file line number Diff line number Diff line change
    @@ -64,13 +64,19 @@ git push -u origin fork
    git switch main
    ```

    👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻
    ## (optional) check the it worked:
    ```bash
    git remote show origin
    git remote show upstream
    ```

    ---

    # Example

    <img src="https://gist.github.com/user-attachments/assets/8e49d620-384f-40f9-8b16-4329e439f830" width="600px">
    <img src="https://gist.github.com/user-attachments/assets/82535aee-2244-4fc4-b484-c29a4a6ad680" width="600px">




  15. devinschumacher revised this gist Apr 27, 2025. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion post.md
    Original file line number Diff line number Diff line change
    @@ -68,7 +68,9 @@ git switch main

    ---

    ![Screenshot 2025-04-27 at 00 45 33](https://gist.github.com/user-attachments/assets/8e49d620-384f-40f9-8b16-4329e439f830)
    # Example

    <img src="https://gist.github.com/user-attachments/assets/8e49d620-384f-40f9-8b16-4329e439f830" width="600px">



  16. devinschumacher revised this gist Apr 27, 2025. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -68,6 +68,11 @@ git switch main

    ---

    ![Screenshot 2025-04-27 at 00 45 33](https://gist.github.com/user-attachments/assets/8e49d620-384f-40f9-8b16-4329e439f830)




    ## How to work privately and use the fork

    Confirmed. You can treat `fork` purely as your “upstream sync” branch and do all your actual work on `main`. Here’s the streamlined flow:
  17. devinschumacher revised this gist Apr 27, 2025. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -16,11 +16,14 @@ tags:
    git clone https://github.com/<ORIGINAL_OWNER>/<REPO_NAME>.git
    ```

    Rename repo to whatever you want:

    ```bash
    # Rename repo to whatever you want:
    mv <REPO_NAME> <NEW_NAME>
    ```

    # go into folder
    cd <REPO_NAME> <NEW_NAME>
    ```

    ## 2. Create a local “fork” branch
    ```bash
  18. devinschumacher revised this gist Apr 23, 2025. 1 changed file with 10 additions and 5 deletions.
    15 changes: 10 additions & 5 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -23,10 +23,8 @@ mv <REPO_NAME> <NEW_NAME>


    ## 2. Create a local “fork” branch

    ```bash
    git checkout -b fork
    git branch --set-upstream-to=upstream/main fork
    ```

    ## 3. Create an empty private repo in your org
    @@ -38,6 +36,7 @@ Rename the existing `origin` (public repo) to `upstream` and add your private re
    ```bash
    git remote rename origin upstream
    git remote add origin [email protected]:<YOUR_ORG>/<NEW_REPO_NAME>.git
    git branch --set-upstream-to=upstream/main fork
    ```

    Verify:
    @@ -57,8 +56,16 @@ git push -u origin main
    git push -u origin fork
    ```

    ## 6. Get to work
    ```bash
    git switch main
    ```

    👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻

    ---

    # How to work privately and use the fork
    ## How to work privately and use the fork

    Confirmed. You can treat `fork` purely as your “upstream sync” branch and do all your actual work on `main`. Here’s the streamlined flow:

    @@ -93,8 +100,6 @@ Confirmed. You can treat `fork` purely as your “upstream sync” branch and do
    - **You never commit on** `fork`—it’s exclusively for pulling in the third-party repo’s updates.
    - All your feature work, bug-fixes, PRs, etc. happen on `main` (or feature branches off of `main`).

    ---

    ### Shortcut: Merging upstream directly into `main`

    If you’d rather skip the extra branch, just do:
  19. devinschumacher revised this gist Apr 23, 2025. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,7 @@ mv <REPO_NAME> <NEW_NAME>

    ```bash
    git checkout -b fork
    git branch --set-upstream-to=upstream/main fork
    ```

    ## 3. Create an empty private repo in your org
  20. devinschumacher created this gist Apr 23, 2025.
    108 changes: 108 additions & 0 deletions post.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,108 @@
    ---
    title: "How to Create a Private “Fork” of a Public GitHub Repo"
    description: "Step-by-step guide to clone a public repo into a private repository in your organization while still pulling in upstream changes."
    tags:
    - git
    - github
    - private-fork
    - cli
    ---

    # How to Create a Private “Fork” of a Public GitHub Repo

    ## 1. Clone the original repository locally

    ```bash
    git clone https://github.com/<ORIGINAL_OWNER>/<REPO_NAME>.git
    ```

    Rename repo to whatever you want:
    ```bash
    mv <REPO_NAME> <NEW_NAME>
    ```


    ## 2. Create a local “fork” branch

    ```bash
    git checkout -b fork
    ```

    ## 3. Create an empty private repo in your org
    - Github.com → New → Repository (Do not initialize with a README, license, or .gitignore. + leave Initialize this repository unchecked)

    ## 4. Re-assign remotes
    Rename the existing `origin` (public repo) to `upstream` and add your private repo as `origin`:

    ```bash
    git remote rename origin upstream
    git remote add origin [email protected]:<YOUR_ORG>/<NEW_REPO_NAME>.git
    ```

    Verify:

    ```bash
    git remote -v
    # origin [email protected]:YOUR_ORG/NEW_REPO_NAME.git (fetch)
    # origin [email protected]:YOUR_ORG/NEW_REPO_NAME.git (push)
    # upstream https://github.com/<OWNER>/<REPO>.git (fetch)
    # upstream https://github.com/<OWNER>/<REPO>.git (push)
    ```

    ## 5. Push branches to your private repo

    ```bash
    git push -u origin main
    git push -u origin fork
    ```


    # How to work privately and use the fork

    Confirmed. You can treat `fork` purely as your “upstream sync” branch and do all your actual work on `main`. Here’s the streamlined flow:

    1. **Clone your private fork**
    ```bash
    git clone [email protected]:YOUR_ORG/NEW_REPO_NAME.git
    cd NEW_REPO_NAME
    ```

    2. **Ensure your remotes are set**
    ```bash
    git remote add upstream https://github.com/ORIGINAL_OWNER/REPO.git
    # (only if you haven’t already)
    ```

    3. **Update the `fork` branch from upstream**
    ```bash
    git checkout fork
    # make sure fork tracks upstream/main:
    git branch --set-upstream-to=upstream/main fork

    git pull # fast-forwards fork ← upstream/main
    ```

    4. **Merge upstream changes into your `main`**
    ```bash
    git checkout main
    git merge fork # brings in all upstream updates
    git push origin main # pushes your updated main to your org
    ```

    - **You never commit on** `fork`—it’s exclusively for pulling in the third-party repo’s updates.
    - All your feature work, bug-fixes, PRs, etc. happen on `main` (or feature branches off of `main`).

    ---

    ### Shortcut: Merging upstream directly into `main`

    If you’d rather skip the extra branch, just do:

    ```bash
    git fetch upstream
    git checkout main
    git merge upstream/main
    git push origin main
    ```

    Either pattern keeps your `main` clean and your “sync” branch dedicated solely to upstream updates.