Consider our workshop 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
- Forking in progress
-
Clone the repo. Open your terminal. Go to the path where you want to have your repo on your local machine.
git clone <ssh-url>
Note: You will be cloning the repository which is a fork of our repository also called upstream in this case.
hnalla@workstation ~/Demo $ git clone [email protected]:harshad16/intern-bootcamp-git.git
Cloning into 'intern-bootcamp-git'...
remote: Enumerating objects: 40, done.
remote: Counting objects: 100% (40/40), done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 40 (delta 9), reused 33 (delta 5), pack-reused 0
Receiving objects: 100% (40/40), 414.84 KiB | 4.66 MiB/s, done.
Resolving deltas: 100% (9/9), done.
-
Enter the clone repo,
cd intern-bootcamp
-
Check remote
git remote -v
.
You should see url of your repository. Something like
https://github.com/<your_github_account_name>/<repository_name>.git
.hnalla@workstation ~/Demo/intern-bootcamp-git (master) $ git remote -v origin [email protected]:harshad16/intern-bootcamp-git.git (fetch) origin [email protected]:harshad16/intern-bootcamp-git.git (push)
-
Add upstream to remote
git remote add upstream <upstream repo link>
i.egit remote add upstream [email protected]:anishasthana/intern-bootcamp-git.git
-
Check remote again
git remote -v
. Now you should see two remotes, namelyupstream
andorigin
. Verify if the urls are corect.upstream
should be our repo url.origin
should be your repo url.hnalla@workstation ~/Demo/intern-bootcamp-git (master) $ git remote -v origin [email protected]:harshad16/intern-bootcamp-git.git (fetch) origin [email protected]:harshad16/intern-bootcamp-git.git (push) upstream [email protected]:anishasthana/intern-bootcamp-git.git (fetch) upstream [email protected]:anishasthana/intern-bootcamp-git.git (push)
-
Check current branch
git branch
* master (END)
-
Add new branch
git checkout -b feature
-
Check the contents of the repo
ls
-
Open the file
attendees.txt
and add a your name and email id,Harshad [email protected]
-
Save the file.
-
Add the file to stage for git to track
git add attendees.txt
-
Make a commit
git commit -m "My first upstream contribution"
-
Push the file
git push origin feature
-
Verify if the file was pushed by checking it on GitHub web page.