DEV Community

MANIKANDAN
MANIKANDAN

Posted on

A Simple Guide to Creating, Pushing & Pulling Your First Repository"

** Why do we need git first? **
To connect all team members in one place, we use git, which makes it easier for developers to share code.

The main thing is that it is used to track our daily progress from day one, making it more consistent.

Version control is one of the reasons why most people choose
git

Figure 1 will help you understand version control.

Code Backup:- Your code is stored both locally and remotely(gitlab or any version control )so it's safe

What is git ?

-> Git is an open-source tool that helps us track changes in our
file, can work with teammates on the same project, and store
work histories.

*How to push and pull code between local and remote repositories *

  1. First, create an account in GitLab or GitHub, but we are going to
    Use GitLab.

  2. After creating the GitLab account, create a project or repository
    In Gitlab

  1. Click new project

  1. Create a blank project

  1. Now your repository has been created successfully

NOTE:-After going to the code box, copy the clone with the HTTPS link.

------NOW THE REMOTE REPOSITORY HAS BEEN CREATED SUCCESSFULLY--------

NOW WE CAN MOVE TO LOCAL REPOSITORY

  1. Create a folder in the local, which is nothing but a normal folder creation
  2. Now right-click the folder --> NEXT open in terminal

  3. Type in the terminal --> git clone(---like that you copied from
    remote repository --> press enter

Note:- ctrl+v will not work in the terminal, so paste the link
manually

  1. Now open that folder, you will see there will be a new folder by
    by the name which you have created in the remote repository, if
    You click that folder, and in that, you will see a README.md file
    If it is showing that you have cloned the repository successfully

  2. For pushing a file or folder from the local to the remote

    repository for doing this, create a file in the local repository

  1. Now right-click --> open in terminal

  2. Type git status

Now, change that folder location to the cloned folder for that type
cd folder name

  1. Now type git status

  1. Type git add (file name ) --> press enter

  1. Commit the file is just a message before pushing to the repository Type:- git commit --m "What message you want to pass " press enter

  1. PUSHING THE FILE TO THE REPOSITORY Type :- git push

--> After that, it will ask for your username and password
--> If you have not set the user name and password, follow
the steps
--> Go to the start, type terminal
--->git config --global user.name "Your Name"
--->git config --global user.email "youremail@example.com"
---> change your-name and your email id

  1. Now go to GitLab and see that you will find the new file -->Before that, reload the GitLab page

![ ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36kphdjwua889chb1qxv.png

FOR PULLING FROM THE REMOTE REPOSITORY TO THE LOCAL REPOSITORY

  1. Create a file in gitlab remote repository

New file created

  1. Now go to the folder terminal and type git push

  1. Check in your local repository now

IF THERE IS A PROBLEM IN GIT, DON'T FIND OUTSIDE, FIND IN GIT

ITSELF, EVERY SOLUTION WILL BE THERE IN GIT 
Enter fullscreen mode Exit fullscreen mode

Follow this steps -----> git status --> git add --> git commit --m""
--->git push

Top comments (3)

Collapse
 
anik_sikder_313 profile image
Anik Sikder

This guide is super helpful for beginners! I remember struggling with my first push/pull workflow especially figuring out where to paste the clone link and how commits actually work. The step-by-step format makes it easy to follow, and I love the reminder that most Git problems can be solved with git status. Thanks for making this so clear!

Collapse
 
manikandan_a8f99e0153ef77 profile image
MANIKANDAN

Thank you 😊

Collapse
 
bearai profile image
Bear AI

Well explained!