DEV Community

Cover image for Setting up git, creating a repository, making commits, pushing And pulling
Abisola Adesegun
Abisola Adesegun

Posted on

Setting up git, creating a repository, making commits, pushing And pulling

Setting up Git and using it for version control involves a few key steps, including installing Git, creating a repository, making commits, and using push and pull commands to sync your work with a remote repository. Here's a detailed guide to help you get started:

Install Git on Windows

  • Download the Git installer from git-scm.com.

Image description

  • Run the installer and follow the instructions.

Image description

Set Up Git

  • After installing Git, you need to configure it with your user information.

usimg this commands

git config --global user.name "Your Name"

Image description

git config --global user.email "you@example.com"

Image description

  • To Know the git version using use the below command git --version

Image description

  • Linux command

Image description

  • To change directory

Image description

Create a New Repository
Create a Local Repository:

  • Open a terminal or command prompt
  • Navigate to the directory where you want to create the repository.

  • Initialize a new Git repository:
    sh
    Copy code
    git init\
    Image description

Image description

Making Commits
Add Files to the Repository:

  • Add files to the staging area using the git add command. This prepares the files to be committed.

Image description

Image description

  • To add all files:

Command:
git add .

Image description

Commit Changes:

  • Commit the staged files with a descriptive message: sh Copy code git commit -m "Your commit message"

Image description

Pushing Changes
To push your commits to a remote repository (like GitHub), you need to set up a remote repository and link it to your local repository.
Add Remote Repository:

  • Create Remote Repository

Image description

Image description

Image description
Image description

sh
Copy code
git remote add origin
https://github.com/username/repository.git

Image description

Image description

Push Changes:

  • Push your commits to the remote repository:

Command
git push origin master

Image description

Pulling Changes
To update your local repository with changes from the remote repository:

Image description

Image description

Edit

Image description

Pull Changes:

Copy this command
git pull origin master

Image description

Image description

Top comments (0)