Git tutorial

Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 5

Q1. What is Git?

Git is a DevOps tool used for source code management. It is a


free and open-source version control system used to handle
small to very large projects efficiently. Git is used to tracking
changes in the source code, enabling multiple developers to
work together on non-linear development.

Q2. Difference between Git and GitHub.


Git is a free, open-source software distributed version control
system (DVCS) designed to manage all source code history.
Meanwhile GitHub, is a web-based hosting service for Git
repositories.

 Some basic terminologies used in the git


1. Repository/repo
It can be considered as an empty folder during the initial
stage. Later on, we can fill the repository with files and the
changes we are doing in it.
2. Staging area
It can be described as an area which shows that what files
are going to be changed after the commit.
3. Remote branch
It is the branch name of the repository which we have
cloned.
Q3. How to install git on windows and linux distributions?
For Windows Users
- Go to google and search git bash
- https://git-scm.com/downloads
- Open the above link and install the latest version of the git
bash.
- After downloading install the software by following the
recommended settings.
For Linux Users
- Get superuser access thorough sudo su.
- Enter your password of the pc to enable superuser access.
- Now type this command
sudo apt-get update
sudo apt-get install git

Q4. How to push to an initial commit in an empty


repository?
i. Create an empty repository.
ii. Initialise and empty local repository.
iii. Now type git status to check the files.
iv. Add all the changes in the staging area.
v. Commit all the changes.
vi. Remotely add the empty repository.
vii. Change the branch name.
viii. Push in the remote branch.

Commands Required:
- git init
- git status
- git add -A
- git commit
- git remote add in link_of_the_empty_repository
- git checkout -b new_branch_name
- git push in new_branch_name
Some necessary git commands needed by the developer.
 git init
This command initialises a empty git repository in the
current working directory.
 git add -A
This command adds all the changed files in the staging
area.
 git commit
This command used to save your changes to the local
repository.
 git push -f
This command pushes your local changes to the repository
on the GitHub. To perform this action GitHub username
and token is required.
 git clone
This command downloads the repository to your local
machine or pc.
 git cherry-pick
This command helps to pick a specific feature from
different repository.
This command is powerful and it generates HEADS during
the execution of command. These HEADS need to be
resolved in order to cleanly pick a feature.
 git rebase
This is the most powerful command in git. This command
has power to remove any unwanted commit and it also has
power to fix any mistake occurred in the previous commit.
This command can take an hour to understand. So, we will
discuss about this in any other session.

git commit --amend --date="Sun April 23 22:00


2023 +0530"

git remote add branch repo_link


git fetch branch
git cherry-pick hash_code
git push -f

You might also like