Push and Pull Commands in Git

Push and Pull Commands in Git

By - Amol Shende4/29/2025

Learn the Push and Pull Commands in Git with this simple guide. Understand how to sync your local and remote repositories effectively using Git CLI commands.

 

Clone → Push Workflow

Objective :-  Here user    originaluser@gmail.com  is the owner and   newuser@gmail.com  want to clone the code make changes and then push it on owner's repository.

originaluser@gmail.com    system

git –version

git config - -global user.name “Original User”

git config - -global user. email  originaluser@gmail.com

git config - -list

mkdir git-project

cd git-project

nano index.html

<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>

git init

git add .

git commit -m " Introduced index.html - handcrafted by the Original User"

git remote add origin  https://github.com/originaluser/repository-name.git

git push origin master

 

[Now check code on Git Repository of original user.  Code is available with one commit.]

Now new user want to clone the code, commit changes and then push it on originaluser repository.

newuser@gmail.com        system

sudo su –

yum install git

git  - -version

git config --global user.name "New User"

git config --global user.email “newuser@gmail.com

git config --list

git clone https://github.com/ originaluser / repository-name.git

cd repository-name

ls                      -- > shows index.html

git log             -- > shows one commit

Add one more file, stage and commit it

nano test.html

       Added line for test

git add .

git commit -m “Committing something   by new user”

git log     -- > shows two commits.

Explore Other Demanding Courses

No courses available for the selected domain.

Want to push code on original user repository.

Note: Join the best Linux Classes in Pune to master Linux commands, shell scripting, and system administration with expert trainers at SevenMentor. Enroll now!

 

Grant NewUser Access to the Repository   ( By original user )

  • Login to GitHub with originaluser@gmail.com.
  • Open repository where the code is pushed earlier.
  • Click on Settings (top right).
  • In the left sidebar, click Collaborators.
  • Click Add people and enter newuser@gmail.com.
  • Select Write access and send the invite.
  • NewUser must accept the invite from the email or GitHub notifications.

Generating a GitHub (PAT)Personal Access Token ( By original User)

  • Login to GitHub with originaluser@gmail.com.
  • Click on the profile picture (top-right) then select Settings.
  • Open Developer settings → Personal access tokens → Tokens (classic).  Under left sidebar
  • Now Click on Generate new token → Generate new token (classic).
  • Give the token a name like "Access for DevOps User".
  • Set expiration date for PAT (choose “No expiration” if you don’t want it to expire soon).
  • Under Scopes, select:
    •  repo (Give full control of private repositories)
  • Click Generate token.
  • Need to copy the token immediately (you won’t see it again – It’s in encrypted form).

 

On NewUser system 

 

git push https://TOKEN@github.com/originaluser/repository-name.git

git push origin master

 

Fork → Pull Request Workflow

Fork the Repository (NewUser)

  • Login to github account of newuser.
  • Fork repository   https://github.com/ originaluser / repository-name.git
  • New repository gets created NewUser GitHub account by use of Forking.
  • Clone the forked repository (NewUser System)

git clone https://github.com/newuser/ repository-name.git

 

cd repository-name

git status

git add .

git commit -m "Updated code by NewUser"

 

Push the changes to NewUser’s forked repo:

git push origin master

Create a Pull Request (NewUser)

  • Go to NewUser’s forked repo on GitHub:
    👉 https://github.com/NewUser/ repository-name.git 
  • Click "Contribute" → "Open Pull Request".
  • GitHub will show the changes and allow Original user to request merging into the original repository.
  • Click on  "Create Pull Request" and add give  description of the changes.
  • originaluser@gmail.com (Original User) will receive a request to review and merge the changes.

Merge the Pull Request (Original User)

  • Original User logs into GitHub and opens the original repository.
  • Go to the Pull Requests tab.
  • Changes need to be Reviewed and merge the Pull Request.
  • The changes from NewUser fork will now be available on the original repository.

 

Do visit our channel to learn more: Click Here

Author:-

Amol Shende

Get Free Consultation

Loading...

Call the Trainer and Book your free demo Class..... Call now!!!

| SevenMentor Pvt Ltd.

© Copyright 2025 | SevenMentor Pvt Ltd.

Share on FacebookShare on TwitterVisit InstagramShare on LinkedIn