Grab a repository and add it to your GitHub account For these examples, we're going to use the "test-repo" in the organization (https://github.com/hungry-franklin-257fd8/test-repo).
-
Go to the repository that you want to fork.
-
Near the top right of the screen there will be a "Fork" button. Click it and add it to your account.
Use the repository you forked in "Forking the repository to your GitHub account".
-
Change directory in the command line to the directory you want to clone (copy) the repository into:
cd Desktop
. -
Go to the repository in GitHub and near the top right, click the green "Code" button. Select "HTTPS" and copy the command:
https://github.com/hungry-franklin-257fd8/test-repo.git
. -
Go back to your command line and paste
git clone https://github.com/vince1444/test-repo.git
. -
Now change directory into your newly cloned repository (you should still be in the directory you chose for step 1):
cd test-repo
.
We never want to commit to the mainline without reviewing the code.
-
Make sure you're in the root directory of your cloned repo. Example:
C:\Users\Vince\Desktop\test-repo
. -
Add a mainline to tell git what the main branch is:
git remote add mainline github_parent_repository_url
, where "github_parent_repository_url" is the parent repository you forked from.
--Example:git remote add mainline https://github.com/hungry-franklin-257fd8/test-repo
. -
Ensure that you never push to the main branch:
git remote set-url --push mainline no_push
. -
Type in
git remote -v
and you should see on the second linemainline no_push (push)
.
-
Before starting, ensure that you have the latest changes to your local repository:
git pull mainline main
and
git merge mainline main
. -
Make your changes, add files, etc.
-
Add all your changed files to staging:
git add .
. -
Commit your changes with a concise message:
git commit -m "Concise Message"
. -
Upload your local changes to GitHub:
git push origin main
.
Pull requests are used to review code before committing them to the production branch.
-
Go into your forked repository in GitHub.
-
Near the top left, click "Pull Requests".
-
Hit the green "New pull request" button and then the green "Create pull request" button.
-
Give a detailed title & description and submit the pull request.
-
When available, everyone can get together and we can review the code to make sure it works as intended without bugs.