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
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”
- 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
- 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.
- Name your repository and click Create repository.
- Copy the repository’s URL and link it to your local repository:
- nano read.md
Press control X, then press Y then press enter
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 commit -m “added readme file”
- 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.
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