0% found this document useful (0 votes)
1 views

git_push_pull

git

Uploaded by

Aravind P
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

git_push_pull

git

Uploaded by

Aravind P
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

PUSH & PULL BY NIDISH RAO

EMP ID : 13076

COMMANDS
What is Git?
Git is a version control system for tracking changes in
computer files. It is used for coordinating work among
several people on a project and tracking progress over time.

Someone else’s work isn’t available for all and branched from master branch

Someone else’s work is PUSHED and made available in master branch


What is GitHub?
 GitHub is a Git repository hosting service, which
provides web-based graphical interface
 GitHub helps every team member to work together on
the project from anywhere and makes it easy for them
to collaborate

What is Git Push?


 Git Push is used to push the local repository (PC) content
to a remote repository
 After a local repository has been modified a push is
executed to share the modifications with remote team
members
What is Git Pull?
 Git Pull is used to fetch and merge changes from the
remote repository to the local repository
 Git Pull is a combination of two commands, git fetch
followed by git merge

To perform Git Pull and Push operations we need a


repository where we will store all the files/folders for
this we have GitHub but to perform Git Pull and Push
operations we need Git Bash which is a Git Command
Line Experience.

To download Git bash : git-scm.com/downloads


Steps to Create a Repository

Step 1 : Navigate to GitHub

Step 2 : Create your account if its not created

Step 3 : On home page click on “NEW” to create a


repository

Step 4 : Creating a new repository


 Name the repository
 Give description of your repository
 Make it Public so that it can be seen by any individual
 Click on Create repository
Step 5 : After creating the repository you will land up to
your github repository configuration page.

The link present is used to push or pull the files to your


repository.

The link to our repository is :


https://github.com/nidishnrao/MyFirstRepository.git
Steps to Push the files in the new repository we
created

Step 1 :
Open Git Bash and check the default directory of Git bash on
your local machine by typing below command in Git bash.
COMMAND : pwd

Step 2 :
We can make a folder containing all the files manually in a
directory or by using the command.
COMMAND : mkdir MyFiles
Step 3 :

Now we need to go inside the folder we created we


can do that using the command and check directory by
following Step 1 of Steps to Push the files in the new
repository we created

COMMAND : cd MyFiles
(cd – Change Directory)
Step 4 :
We will initialize Git command for our folder using the
command.
COMMAND : git init
(init – initialize)

In our MyFiles Folder you can see a .git folder


(NOTE : DONOT MAKE ANY CHANGES IN THIS FOLDER)
As it contains directories and configurations for your git
repository
Step 5 :
Copy and paste the files to be put up in GitHub in the folder
that we created “MyFiles” or We can use the following
command to add a text file and add contents in it and save it.
COMMAND : touch MyFirstText.txt
COMMAND : notepad MyFirstText.txt
Step 6 :
Now, Check the status of the files present / added in this
folder by using the command.
COMMAND : git status

The command gives a message saying “No commits yet”


We can see the untracked files in red colour in git bash
console as we created earlier a text file named “MyFirstText”.

Step 7 :
To add the untracked files we use the following command.
COMMAND : git add .
(NOTE : After git add there is a space and then a fullstop (.) )
After executing Add command repeat Step 6 to see the status
of the untracked files. You will see the files are now tracked
in green colour in git bash console.

However, the files are not committed yet (“NO COMMITS


YET”) as seen in git bash console.

Step 8 :
To commit the changes we use the following command.
COMMAND : git commit –m “Added first text file”

Changes have been committed.


Step 9 :
When all the changes are done now we will share these files
with someone and work in a collaborative way so that we
push the repository to GitHub.

From step 5 of steps to create a repository copy


the repository link and use the following command.

COMMAND : git remote add origin


https://github.com/nidishnrao/MyFirstRepository.git

Step 10 :
Pushing the files into the repository
Step 11 :
Go to your Git repository and refresh
(If in case after pushing in Step 10 it prompts to login with
browser. Login with your Git Account for verification and
authorize the Git dependency then refresh)

You have successfully created your first repository and


pushed files into it.
Now to make changes in the files that we pushed in our git or
add new files into git inorder to do this we need to use PULL
operation.
Steps to Pull the files from the repository we
created

Step 1 :
Open Git Bash and check the default directory of Git bash on
your local machine by typing below command in Git bash.
COMMAND : pwd

Step 2 :
We can make a folder containing all the files manually in a
directory or by using the command.
COMMAND : mkdir MyGitFiles

Step 3 :
Now we need to go inside the folder we created we can do
that using the command and check directory by following
command.
COMMAND : cd MyFiles
(cd – Change Directory)
Step 4 :
We will initialize Git command for our folder using the
command.
COMMAND : git init
(init – initialize)
Step 5 :
We will go to the repository from where we need to pull the
files for this we go to our GitHub repository Click on code and
copy the HTTPS link.

The link to our repository is :


https://github.com/nidishnrao/MyFirstRepository.git

Step 6 :
Now we will pull the contents of git repository in our folder
(i.e “MyGitFiles”) to pull use the following command.
COMMAND : git pull
https://github.com/nidishnrao/MyFirstRepository.git
In MyGitFiles folder now you will find the text file
which was present in repository

You have successfully pulled the contents from our first


repository into our local repository.
Now to make changes in the files that we pushed in our git or
add new files into git inorder to do this we need to use PUSH
& PULL operation.
Steps to Push & Pull the files to the repository we
created

If we want to modify file or add new file or delete a file


which was exisiting in the Git we will perform Git Push
& Pull operation, Simultaneously

Step 1 :

In continuation to the Step 6 of Steps to Pull the files from


the repository we created. We are still in MyGitFiles folder
containing a text file from the repository we pulled it from.

Now, we will make changes in the text file we have in the


folder. Use following command to open text file and make
changes in it.

COMMAND : notepad MyFirstText.txt


Text file opens modify the contents of text file and save it.

Step 2 :
Now we will add a new file either manually by copying the
files into the folder directly or by using the git bash
command.
COMMAND : touch MySecondText.txt
COMMAND : notepad MySecondText.txt

Add some content in the new text file created and save it.
Now will find 2 text files under MyGitFiles folder.
In which “MyFirstText” file is the modified one & the
“MySecondText” file is the new file created.
Step 3 :
Now, Check the status of the files present / added in this
folder by using the command.
COMMAND : git status

As we can see the first text file is modified as we have made


changes in the contents of it. While second text file is
untracked as it is the new file that has been added.
Step 4 :
To add the untracked files we use the following command.
COMMAND : git add .
(NOTE : After git add there is a space and then a fullstop (.) )
After executing Add command repeat Step 3 to see the status
of the untracked files. You will see the files are now tracked
in green colour in git bash console.

Step 5 :
To commit the changes we use the following command.
COMMAND : git commit –m “Added Second text file and
modified the first text file”

Changes have been committed.


Step 6 :
When all the changes are done now we will share these files
with someone and work in a collaborative way so that we
push the repository to GitHub.

From step 5 of steps to create a repository copy the


repository link and use the following command.

COMMAND : git remote add origin


https://github.com/nidishnrao/MyFirstRepository.git

Step 7 :
Pushing the files into the repository
Step 8 :
Go to your Git repository and refresh
(If in case after pushing in Step 7 it prompts to login with
browser. Login with your Git Account for verification and
authorize the Git dependency then refresh)

You have successfully Pushed & Pulled the contents from


your local repository to Git repository and viceversa.

You might also like