What is Git?
Git?
Git is a free, open-source version control software. It was created by Linus Torvalds in 2005. This tool is a version control system that was initially developed to work with several developers on the Linux kernel.
This means that Git is a content tracker. So Git can be used to store content and it is mostly used to store code because of the other features it provides.
GitHub?
GitHub is an online software development platform. It's used for storing, tracking, and collaborating on software projects.
It makes it easy for developers to share code files and collaborate with fellow developers on open-source projects. GitHub also serves as a social networking site where developers can openly network, collaborate, and pitch their work.
Version Control?
A version control system is software that tracks changes to a file or set of files over time so that you can recall specific versions later.
The version control system is a collection of software tools that help a team to manage changes in a source code. It uses a special kind of database to keep track of every modification to the code.
Local Version Control Systems: maintains track of files within the local system. This approach is very common and simple.
Centralized Version Control Systems: all the changes in the files are tracked under the centralized server. Here, there’s a central repo shared with all the developers, and everyone gets their own working copy. Whenever you commit, the changes get reflected directly in the repo.
Distributed Version Control Systems: There is a local copy of the repo for every developer on their computers. They can make whatever changes they want and commit without affecting the remote repo. They first commit to their local repo and then push the changes to the remote repo. This is the type used majorly today.
Git installation
Install Git on Mac
brew install git
git --version
Configure user
We can config users using email and username by using the following commands.
git config --global user.mail "ibrahimsi454@gmail.com"
git config --global user.name "Ibrahimsi"
Initialize a local repository
git init <directory>
Clone a repository
git clone <repository-url>
Add a file to the staging area
git add <file>
Add all file changes to the staging area
git add .
Check the unstaged changes
git diff
Commit the staged changes
git commit -m "Your Message"
Reset the staging area from the last commit
git reset <file>
Check the status of the working directory
git status
Remove a file from the index and working directory
git rm <file>
List the commit history
git log
A branch is a new/separate version of the main repository.
To display branches
git branch
To create a branch
git branch <branch name>
To switch to a branch
git checkout <branch name>
To delete a branch
git branch -d <branch name>
To merge a branch
git merge <branch name>
Pull changes from a remote repository
git pull <remote name>
Push changes to a remote repository
git push <remote> <branch-name>
Push a branch into a remote repository
git push origin master
Changes the Git remote associated with a repository
git remote -v
git remote set-url origin <github id>
Git cherry-pick is a command that allows you to select specific commits from one branch and apply them to another.
This can be useful when you want to selectively apply changes that were made in one branch to another.
git cherry-pick <branch name>
Locally store your recent changes in a separate area so you can fetch those changes later.
git stash
Combine multiple commits into one
git squash
git merge --squash <branch_name>
Rebasing is the process of moving or combining a sequence of commits to a new base commit
git rebase <branch_name>
“Fatal Authentication” problem in GIT while uploading local repository content to a remote repository.
When we push any file to a remote repository over Github, sometimes we encounter a “Fatal Authentication” error.
To resolve this issue, follow the given steps: Generate a Token and give the “git remote set-url origin” command: To do the same, follow the steps given below-
Open GitHub and log in with your valid credentials
Go to and click on “Settings”.
Navigate to “Developer settings” and click on it.
Click on “Personal access tokens” and select “Tokens(classic)”.
Click on “Generate new token” and then click on “Generate new token(classic)”.
Give the mandatory information and click on Generate token.
A token will be generated. Copy it and save it in notepad for later use.