Complete Tutorial of Git and GitHub for Basic to Advanced

Hello! I am a passionate cloud enthusiast who is constantly seeking to expand my knowledge of emerging technologies and techniques. My primary focus revolves around AWS, Terraform, Azure, and Docker. Through my journey, I aim to explore and understand the intricacies of these platforms while embracing their potential to drive innovation and efficiency in cloud computing. As a result, I am excited to share my insights and experiences through informative blog posts, providing valuable resources to fellow cloud enthusiasts and those eager to learn more about these technologies. Join me on this exciting adventure as we navigate the ever-evolving world of cloud computing together!
What is Git ?
Git is a tool that helps developers keep track of changes they make to their code. It’s like a time machine for your projects, letting you see what you’ve done and work with others easily.
To install Git, click here Git installation page.
Git Workflows:

Local repository: Your project’s files are stored in a folder on your computer.
Working directory: This is where you actively make changes to your project’s files, inside your local repository.
Commit: Saving a snapshot of your changes, along with a message describing what you did. (git uses SHA 1 checksum concept for tracking changes.)
Local repository (on hard disk): All your commits are permanently stored on your computer.
GitHub repository (online storage of code): A copy of your local repository stored on GitHub’s servers.
Push: Sending your local commits to your GitHub repository.
Pull: Getting the latest changes from GitHub to your local repository, useful for collaboration.
Live Demo of Git :
- Create a folder at your desired location

2. Open this terminal inside VS code and in VS code terminal type git init

3. Now create a file ( in my case I create index.html) and add in file something.

4. In terminal type git add . and check status by git status. Congratulations, you add your file in staging area.

5. Now Commit this file by using :
git commit -m "First commit in the code"When you type this command and press enter, you will see the following screen :

This tell you please configure your name and email before committing.
Plain Text
git config --global user.name "user name" git config --global user.email "user@gmail.com" git commit -m "first commit"Congratulations, you commit your first file, i.e. it save in you local repo.
6. Now if you want to upload on GitHub(Before this please create your account on GitHub and create there a new repository), and in terminal type below code :
Plain Text
git remote add origin https://github.com/taruncodeplace6666/demollm.git git branch -M main git push -u origin mainCongratulations, your files are reaching at GitHub.

Some important Commands for Working with the github repository :
git log: This command shows a history of commits in a repository, displaying information like commit messages, authorship, and timestamps, helping developers understand the project’s evolution.
Plain Text
git log
git show : With this command, developers can view detailed information about a specific commit, including changes made to files, providing insights into what was modified and why.
Plain Text
git show
.gitignore file : This file specifies intentionally untracked files that Git should ignore, such as temporary files or build artifacts, preventing them from being included in commits and cluttering the repository. It helps keep the repository clean and focused on important files.

git branch :
A Git branch is a separate line of development within a Git repository. It allows developers to work on new features, fixes, or experiments without affecting the main codebase. Each branch represents a distinct set of changes, and developers can create, switch between, merge, and delete branches as needed. Branches are important because they enable parallel development, collaboration among team members, experimentation with new ideas, and the isolation of changes for testing and review, all while keeping the main codebase stable and unaffected.
Here’s a breakdown of the Git huh workflow in branch :
Create a Branch: You typically start by creating a new branch from the master branch. This creates a copy of the master branch where you can work on your changes without affecting the main codebase.
Make Changes: In your local branch (Your Work), you make changes to the code.
Commit: When you’re happy with your changes, you commit them to your local branch. This creates a snapshot of your changes at that point in time.
Push: Once you’ve committed your changes, you can push them to a remote repository like GitHub. This creates a remote copy of your local branch.
Pull Request: When you’re ready to share your changes and have them merged into the master branch, you create a pull request on GitHub. This notifies other developers of your changes and allows them to review your work before merging.
Merge: If your changes are approved, they can be merged into the master branch. This integrates your work into the main codebase.
Plain Text
# To see list of available branches
git branch
# To Create new branch
git branch <branch name>
# To switch branch
git checkout <branch name>
# Files created in workspace will be visible in any of the branch workspace
# untill you commit. Once you commit, then that files belongs to that particular
# branch.
git merge :
Git merge is a command used to integrate changes from one branch into another branch. It combines the changes made in a source branch with the target branch, resulting in a new commit that incorporates the changes from both branches.
Suppose, you have two branches named main and Develop. You want to merge features branch to main branch then you first go inside the main branch by :
Plain Text
git checkout mainand from here use following command :
Plain Textgit merge DevelopIn this way, you can merge one branch to other and after that you can push these changes to GitHub.
git reset :
Git reset is a command used to undo changes in your working directory to staging area.
Plain Text
git reset <file name> or git reset .See the workflow of git reset :

i had first index.html in my folder now i have welcome.html in my folder
Tags :
It is used to gives meaningful names to a specific version in the repository.
Plain Text
git tag -a <tag name> -m <message> <commit-id> # To see the list of tags git tag # To see particular commit content by using tag git show <tag name> # To delete a tag git tag -d <tag name>mv :
It is used to rename files or directories and to move them from one location to another in the system
Plain Text
git mv <Previous file><New file name>rm :
It is used to remove (delete) files or directories from the system.
Plain Text
git rm <Previous file><New file name>
I hope this blog has enhanced your comprehension of the git and github concept. If you’ve gained value from this content, consider following me for more insightful posts. Appreciate your time in reading this article. Thank you!


