Git/C3/Working-with-Remote-Repositories/English
Title of script: Working with Remote Repositories
Author: Priya K
Keywords: Video tutorial, Git, GitHub, repository, remote repository, clone, pull data, push data
|
|
Slide 1:
Working with Remote Repository |
Welcome to the spoken tutorial on Working with Remote Repositories. |
Slide 2:Learning Objectives
|
In this tutorial, we will learn -
|
Slide 3:
System requirement For this tutorial, I am using
|
For this tutorial, I am using
You can use any editor and web browser of your choice. |
Slide 4:
Pre-requisites
|
For this tutorial, you will need a working Internet connection.
|
Slide 5:
Remote repository
|
First let us understand what is a Remote repository.
|
Slide 6:
Working with Remote repository[[Image:]] |
Say, for example, there are 3 users who want to work jointly in the same repository.
|
Open GitHub repository | First we will open our GitHub repository which we created earlier. |
Point to URL | In the right side, we can see the URL of this repository. |
Copy the URL | Let’s copy this URL.
|
Open terminal and type cd Desktop and Enter, Type ls and Enter
|
Let’s open the terminal.
|
Type cd User1 and Enter
|
In the same terminal, I will open the directories in 2 different tabs.
|
Click on the tab User1 | Let us go to the tab User1. |
Type git clone URL .
|
Now let us make a copy of the Remote repository.
|
Highlight . (dot) | Dot indicates that we are going to copy the repository inside the same directory i.e. User1.
|
Press Enter | Now press Enter. |
The clone command will copy the whole central folder and make it as a local repository. | |
Type ls and Enter | Type ls.
|
Type git config user.name “priya-spoken1”
git config user.email “priyaspoken1@gmail.com” |
Next, I will change the user name and email id of this repository for better understanding.
|
Type git log --oneline
|
Let us check the Git log.
|
Click on the tab User2
git clone URL . |
Likewise, I will clone the repository inside the directory User2 in the second tab. |
git config user.name “kaushik-spoken”
git config user.email “kaushikspoken@gmail.com” |
Here also I will change the user name and email id as I did earlier for User1.
|
Next, let us understand how these users will work in the Remote repository. | |
Click on User1 tab
Type ls and Enter |
Let’s check the directory content of User1. |
Let’s say, User1 will be working on a file named lion-and-mouse.html. | |
Type gedit lion-and-mouse.html and Enter | To create the file, type gedit lion-and-mouse.html. |
Copy and paste the code into the file | I will copy and paste some text into this file, from my Writer document, which I had saved earlier.
Likewise, you can add some content in your file. |
Type git add lion-and-mouse.html and Enter | Let's add the file into the staging area.
|
Type git commit -m “Added lion-and-mouse.html” and Enter | Next let us commit the newly added file.
|
Next we have to synchronize the local repository with the main Remote repository.
| |
Slide 7:
Remote
|
* The URL of a Remote repository is called Remote.
|
Now let us learn how to add a Remote. | |
Switch to terminal
|
Switch back to our terminal.
|
Type git remote add stories URL
|
Next let us see how to add a nickname to the Remote.
|
Type git remote and Enter
|
Again to check the Remote list, type git remote.
|
Type git push stories master | Now we will synchronize the local repository with the main Remote repository.
|
Here stories is the Remote name and master is the branch where we update the changes. | |
Press Enter | Now press Enter. |
Type username as priya-spoken1
|
I will type priya-spoken1 as username of User1 and press Enter. |
Type password | Type the corresponding password of User1. |
Recall that I created this username earlier for demonstration purpose.
| |
Highlight unable to access | It throws an error unable to access. |
Why did this error occur?
| |
So now, let us learn how to give access permission to the contributors. | |
Switch back to GitHub repository | Switch back to GitHub repository. |
Click on Settings tab | Click on the last tab - Settings - in the top panel. |
Click on Collaborators link
|
Then click on Collaborators link in the left side box.
|
Point to the text box | Here in the text box, we can add the names of the collaborators.
|
Tyoe priya-spoken1
|
Now I will add the two users priya-spoken1 and kaushik-spoken.
|
Click on Add Collaborator button | Click on Add Collaborator button to add the user as collaborator. |
Type kaushik-spoken | I will also add the other user kaushik-spoken. |
Highlighted the users | You can see here the added names are listed. |
Now we will try to push into the Remote repository. | |
Switch back to the terminal | Switch back to the terminal. |
Type git push stories master and Enter | Type git push stories master |
Type priya-spoken1 and password
|
Give the username and password of the user who has the access to the repository. |
Highlight the output | You can see that we have pushed it successfully. |
Next, let us check the GitHub repository to see whether our changes are updated. | |
Switch to the GitHub repository. | Switch back to the GitHub repository. |
Click on the Code tab | Click on the Code tab. |
Click on Commits link | Let’s check the commit list. |
Point to Added lion-and-mouse.html | You can see that the commit of the collaborator is listed here.
|
Click on User2 tab in the terminal | Next, let us learn how User2 can collaborate with the Remote repository. |
Switch back to the terminal | Switch back to the terminal. |
Let’s say, User2 is working on a file named friends.html. | |
Type gedit friends.html | To create the file, type gedit friends.html. |
Copy-paste the code | I will copy and paste some text into this file, from my Writer document.
Likewise, you can add some content into your file. |
Type git add friends.html | Let's add the file into the staging area. |
Type git commit hyphen m “Added friends.html” and Enter | Next let’s commit the newly added file.
|
Type git push origin master | Next we have to synchronize the local repository with the main Remote repository.
|
Highlight origin
|
Remember that we didn't add Remote to this local repository.
|
Press Enter | Now press Enter.
|
Highlight failed to push | It throws an error which says failed to push. |
Highlight the remote contains work that you do not have locally | Also, it shows the reason for the error: the remote contains work that you do not have locally.
|
Highlight 'git pull ...') before pushing again | It also gives a suggestion to run git pull command to rectify the error. |
So first, we have to pull down the work of User1 and incorporate it into the User2’s local repository.
| |
Type git pull origin master and Enter | Type git pull origin master |
Press ctrl + x | First it will fetch the data from Remote repository then merge it with the local repository.
|
Type git push origin master and Enter | Now again, we will try to push the data.
|
Give the username and password of User2. | |
You can see that we could successfully push the data now. | |
Switch to the GitHub repository. | Next let us check the GitHub repository to see whether our changes are updated.
|
Click on the repository name Stories | Click on the repository name Stories. |
Highlight friends.html | You can see that the file friends.html is now added to the repository. |
Click on Commits link
|
Let’s check the commit list now.
|
With this, we come to the end of this tutorial. | |
Slide 8:
Summary
|
Let us summarize.
|
Slide 9:
Assignment
|
As an assignment
|
Slide 10:
Acknowledgement
|
The video at the following link summarises the Spoken Tutorial project.
|
Slide 11:
Spoken Tutorial Workshops
|
The Spoken Tutorial Project Team conducts workshops and gives certificates to those who pass online tests.
|
Slide 12:
Acknowledgement
|
Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
|
This is Priya from IIT Bombay. Thanks for joining. |