Skip to content

Latest commit

 

History

History
66 lines (31 loc) · 2.3 KB

4-FORK.md

File metadata and controls

66 lines (31 loc) · 2.3 KB

Steps for forking an upstream repository

Step 1. Fork the upstream repository in your GitHub account.

Consider your teammate's repository as the upstream repository you will be making a contribution to. Follow the screenshot to fork your upstream repository. If you have multiple account (e.g. in the picture), select an account

Fork upstream repo

  • Forking in progress Forking

Step 2. Clone the forked repo

Cloning

  • Clone the repo. Open your terminal. Go to the path where you want to have your repo on your local machine.

  • cd ~/<path where you want to clone your repository> on UNIX/MAC

  • cd C:\<path where you want to clone your repository> on Windows

  • git clone <repo-name>

Note: You will be cloning the repository which is a fork of your teammate's repository also called upstream in this case.

git clone console

  • Check remote git remote -v. You should see url of your repository. Something like https://github.com/<your_github_account_name>/<repository_name>.git for e.g. https://github.com/husky-parul/github-commands.git

git remote -v console

  • Add upstream to remote git remote add upstream <upstream repo link>

  • Check remote again git remote -v. Now you should see two remotes, namely upstream and origin. Verify if the urls are corect. upstream should be your teammate's repo url. origin should be your repo url.

git add upstream console

Step 3. Add new feature/code by creating a new branch, say feature-1

  • Check current branch git branch

git branch console

  • Add new branch git checkout -b feature-1 git branch console

  • Check the contents of the repo ls

  • Open the file question.txt and add a sentence, This is my first upstream contribution

  • Save the file.

  • Add the file to stage for git to track git add question.txt

  • Make a commit git commit -m "My first upstream contribution"

  • Push the file git push origin feature-1

  • Verify if the file was pushed by checking it on GitHub web page.