Hello Readers! welcome to this Git series of tutorials.
I'll divide this series into different topics, so please hang in there.
For the starting I'll start with basics!
What is a GIT?
Git is a version Control Software which is used to maintain change history of a codebase.
What is a GitHub?
GitHub is a online website which is used to store all these git commit histories.
How to install Git?
To install git on linux host we can use these following commands.
Note: Please refer to the official website if case of any errors!!
# for debian Destros
sudo apt update
sudo apt install git-all
# for RHEL Destros
sudo yum update
sudo yum install git-all
How to confirm successful installation of the Git?
to ensure git is available on the local machine, we can check it's version by using the command!
git --version
How to initialize a Git repository on the local machine!!?
to instalize a git repository on the local machine.
- Step 1 : navigate to the given directory
- Step 2 : initialize the git repository
git init
How to ignore certain files in git?
sometimes there are certain files which we dont want to upload on remote repository. to make this happen, we need to add the name of that file into .gitignore file
echo <filename> >> .gitignore
git add .gitignore
git commit -m "Git ignore file added"
How to manage Git branches
How to create a new branch?
branches contains sequence of commits in git.
we can create or delete as much as branch as we required.
To create new branch
# this command will create a new branch with given branch name
git branch <branch-name>
# this command will create a new branch and switch to that branch
git checkout -b <branch-name>
How to rename a branch
to rename a branch in git, use the given command!
# first switch to the main branch
git checkout <branch-name>
# second use the following command to change the branch name
git branch -m <old-name> <new-name>
How to delete a branch
to delete a branch first we need to switch to other branch reason being we can't delete currently active branch
# change to other branch for example master.
git checkout master
# then run the delete branch command
git branch -d <branch-name>
How to watch the commit history
to watch the commit history we have git log command
git log
How to Add Email and name
- to add email and username we use the following commands
# to add username we use the command
git config --global user.name "Full Name"
# to add email we use the command
git config --global user.email "Email"
Top comments (2)
Well done! 👏
For anyone interested in learning more, you can checkout this free ebook here:
bobbyiliev / introduction-to-git-and-github-ebook
Free Introduction to Git and GitHub eBook
💡 Introduction to Git and GitHub
This is an open-source introduction to Git and GitHub guide that will help you learn the basics of version control and start using Git for your SysOps, DevOps, and Dev projects. No matter if you are a DevOps/SysOps engineer, developer, or just a Linux enthusiast, you can use Git to track your code changes and collaborate with other members of your team or open source maintainers.
The guide is suitable for anyone working as a developer, system administrator, or a DevOps engineer and wants to learn the basics of Git, GitHub and version control in general.
🚀 Download
To download a copy of the eBook use one of the following links:
Dark mode
Light mode
ePub
📘 Chapters
Great... thanks for sharing