A technical blog on Git and Github, how to set up git, creating a repository, making commits, pushing,pulling

A technical blog on Git and Github, how to set up git, creating a repository, making commits, pushing,pulling


Git and GitHub are essential tools for developers and anyone working on collaborative coding projects. Git is a distributed version control system that allows you to track changes to your codebase, while GitHub is a cloud-based platform for hosting and managing Git repositories. In this blog, I will cover how to set up Git, create a repository, make commits, push and pull changes, and work with branches.

Step One
Setting Up Git

  • Download Git from git-scm.com and follow the installation instructions.

  • Install the git into your system

install the git

Step 2: Configure Git

  • After installation, configure your Git user details.

  • Type Git bash on search bar, right click on git bash and run as Administrator

  • Open a terminal and run the following commands:

  • Set your name
    git config –global user.name “Your Name”

usrname

gmail

  • You can verify your configuration using:
    git config –list

Creating a Repository

Step 3: Initialize a New Repository

Navigate to your project directory and initialize a Git repository:
cd Documents

documents

  • git init
    git init

Step 4 : Add a Remote Repository

  • If you want to link your local repository to GitHub, create a repository on GitHub:

  • Log in to your GitHub account.

  • Click on the “+” icon and select New repository.

new Repo

repo 2

  • Name your repository and click Create repository.

new repo
Step 5

  • Copy the repository’s URL and link it to your local repository:

repo

readme

  • nano read.md
    nono md
    Press control X, then press Y then press enter

nano

cat readme

git
Step 6
Making Commits
When you make changes to your project, Git tracks those changes. However, before the changes are saved in Git’s history, you need to commit them.
Input (git status)

git status

  • git commit -m “added readme file”

commit

  • git push -u origin master
    The -u flag tells Git to track the remote repository, making it easier to push and pull in the future.

origin

cat

pull
Pulling Changes from GitHub

john

Conclusion
Git and GitHub are indispensable tools for developers, offering robust version control and seamless collaboration. By understanding how to set up Git, create repositories, make commits, push and pull changes, and work with branches, you’re well-equipped to manage your codebase and collaborate efficiently with others.

With practice, these fundamental Git commands will become second nature, helping you stay organized and productive in your development journey.



Source link
lol

By stp2y

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.