-
From any public repository (GH website) click the upper right
Forkbutton.- A copy of
someones/cool-repositorywill now be in GH atyourname/cool-repository
- A copy of
-
Go to GH
yourname/cool-repositoryand from there, go to the greenCodebutton to copy the git clone command. -
Open a Terminal and clone your forked repository to create a local copy.
cd /path/to/directory/with/github.com git clone <paste from 2. above> cd cool-repository
-
You now have a local copy of your fork of the cool-repository. You probably want to add a
git remoteto track the originalsomeones/cool-repository.git remote -v # you should see 'origin' as 'git@github.com:yourname/cool-repository.git' # now add the 'upstream' git remote add upstream git@github.com:someones/cool-repository.git
-
Continuously keep your local and remote
mainbranch even with someonesmainbranchgit checkout main git fetch --all git rebase upstream/main git push origin main
-
Open a new branch for local development
git checkout -b new-branch
-
Add a new commit to the new-branch and push to your fork in GH
# make changes git add . git commit -m "a new commit" git push origin new-branch
- You might now visit GH to open a PR, comparing
yourname/new-branchtosomeones/main
- You might now visit GH to open a PR, comparing
-
You might want to clean up your branches!
- To remove local development branch
git branch -D new-branch
- To remove development branch from your fork in GH
git push origin :new-branch
NOTE
origin is the default remote name given to a local clone, and upstream is my habit. You can update to anything with:
git remote rename origin anything
git remote rename current updated