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
-
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.
- Check remote
git remote -v
. You should see url of your repository. Something likehttps://github.com/<your_github_account_name>/<repository_name>.git
for e.g.https://github.com/husky-parul/github-commands.git
-
Add upstream to remote
git remote add upstream <upstream repo link>
-
Check remote again
git remote -v
. Now you should see two remotes, namelyupstream
andorigin
. Verify if the urls are corect.upstream
should be your teammate's repo url.origin
should be your repo url.
- Check current branch
git branch
-
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.