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

GIT

Version Control System Why GIT ?

- GIT is a version control system - Real life projects generally have multiple developers
- Its basically means that GIT is a content working in parallel
tracker - Just like the script writers team
- The purposes of GIT is to manage a project, - So they need a version control system like GIT to
or a set of files, as they change over time make sure that there are no code conflicts between
- Version control is a piece of software that them
helps teams or individuals manage their - It allows you to have track of all the changes by
source code over time different contributors to your project
- It tracks changes in a project so that if - Repository
something breaks while you are working on a. A repository is just a file location where you are
it or any updates made storing all the files related to your project
- You can compare the difference between the b. In our case a repository will contain code – based
current project and a previous version of the files
project c. A repository in GIT could be considered similar to
- History of GIT your project folder
a. Linus Torvalds the developer of Linux, d. GIT could track all the changes happening inside
designed GIT in 2005 the folder
b. This led Linus Torvalds to develop their - Track changes
own tool based on some of the lessons a. When previous people collaborate on a project
they learned while using BitKeeper. This b. It’s hard to keep track of revisions, like who
tool was GIT changed what, when, and where those files are
c. The in – joke was that I name all my stored
projects after myself, and this one was c. GitHub takes care of this problem by keeping
named GIT track of all the changes that have been pushed to
d. GIT is british slang for ‘stupid person’ the repository
words by Torvalds - In GIT there’s a little ‘undo’ command for almost
e. There’s a made – up acronym for it, every situation, it makes working more easy
Global Information Tracker, but that’s - Working in GIT saves a lot of time
really a ‘backronym’ - Tracking any changes made or any other update
becomes very simple with GIT
GitHub Installation

- GIT needs a place to host the repository or - GitHub is very easy to install and simple to work
workplace for everyone. Here, GitHub comes with. Installing GitHub on your operating systems:
into the picure a. Open a browser
- There are two ways you can host your b. Visit https://desktop.github.com/
repositories c. Click download for Windows (64bit)
1. Online d. When prompted, click Run
That is on the cloud e. Allow the installation to download and install
2. Offline
That is self – installed on your server
- GitHub owned by Microsoft
- GitHub is a Git repository hosting service
- It hosts the service for everyone like you host
a party
- It provides a web – based graphical interface
- It helps every team member to work together
from anywhere and makes it easy for them to
collaborate
- GitHub helps all the team members to stay
on the same page and stay organized
- Why GitHub ?
a. GitHub allows you to keep both local and
remote copies of your project
b. Now you know that, GitGub allows you
to keep both local dan remote copies of
your project
c. A project that you can publish it among
your team members as they can use it and
update it from there itself
d. The GitHub repository is so large that it - Repository
has 25 million users, which is actually a. Is a virtual storage of your project, it allows you to
more than the population of some country save versions of your code, which you can access
e. It is the world’s largest software when needed
development platform b. To create a new repo, we will use the git init
f. Putting your project to a shared, public command
repository makes it instantly discoverable c. Git init is a one – time command you use during
for those 25M users. the initial setup of a new repository. Executing
g. You can easily discover code written by this command will create a new .git in your
others, learn from it, and even use it for directory
your own projects. - Cloning
h. Version control on GitHuv are very a. The git clone command can makes a local copy of
similar to MS office or Google drive. It the repository and create a working directory
tracks all the changes or updates made to b. You got your virtual storage or repository ready
your project and who makes them. and you know how it’s done
c. What if you want the same repository on your
local computer ?
d. Repository can be cloned just like the youtube
video you can download to watch it when you are
offline
e. Step
1. To clone a repository, go to the repository
page which you want to clone
2. Press clone or download button
3. Copy the code or URL that appears after
pressing the button
4. Press the following command to clone the
repository :

git clone <URL>

5. It would take a few seconds to clone the


repository onto your system, and the cloning is
done
Lets get started How things work

- Important terminologies - How it works (1) – local to remote repository


a. GIT Bash – is a command – line prompt a. If you’re the only person working on your project,
for windows. It allows user to type GIT chances are you’ll never need to set up a remote
commands that make souce code repository. What if you want to share data with
management easier through versioning your teammates ? Local repositories reside on the
and commit history computers of team members
b. The Working Tree – the name itself tells b. Remote repository comes in the rescue
what it means. Working Tree is the area c. A remote repository in Git is a common repository
where you are currently working. It is that all team members use to exchange their
where your files live. This area is also changes
known as the “untracked” area of git d. Every member can access the repository and make
c. Command – one thing you should keep in changes which everyone can access
mind is that the changes will not be saved e. In most cases, such a remote repository is stored
until you explicitly save them. Any on a code hosting service like GitHub or on an
changes to files will be updated and seen internal server
in the working tree. To see what is in f. We have been working only in the local
your woking tree run the command : git repository. Each developer will work in their local
status. This command will show you two repository but eventually, they will push the code
things : into a remote repository. Once the code is in the
1. The files in your working tree remote repository, other developers can see and
2. The files in your staging area modify that code
d. Staging area – the man hired by the script g. let’s create a new repository in GitHub and
writers team for keeping the records of convert the repository from local repository to
updates and changes made. One day one remote repository
of script writer made some changes in the h. step
script or updated the script. So now any 1. Step 1 : after creating a repository on GitHub,
of the script writer wants to specifically you will get a URL for your repository. Copy
see the changed part of the script ? that URL
2. Step 2 : now to point your local repository to
The staging are comes in picture, when the remote repository, use the following
Git starts tracking and saving changes command
that occur in files. You tell git that I want
to track these specific files, then Git git remote add origin [repository url]
moves them from your Working tree to
the staging area 3. Step 3 : in order to push all the code from the
e. Commit – On GitHub, saved changes are local repository into the remote repository, use
called commits. Each commit has an the following command :
associated commit message. It is a
description explaining why a particular git push -u origin master
change was made. Commit messages
capture the history of your changes, so note* this pushes the code from the master
other contributors can understand what branch in the local repository to the master
you’ve done and why branch in the remote repository

I guess you are aware of the word - How it works (2) – branching
commit. The ‘commit’ command is a. What if Rob made some changes in the script and
basically used to save your changes to the the next day Sam erased those changes to make
local repository. They are the core his new update. This is going to be a big cause of
building block units of a Git project anger for Rob when he gets to know. How are
timeline they gonna solve this problem ?
b. Branching is the practice of creating copies of
You can think of Commits as snapshots programs or objects to work in parallel versions,
or milestones along the timeline of your retaining the original and working on the branch
Git project. They are created with the git or making different changes to each
commit command to capture the state of c. For example, you’re going to have a bunch of
a project at that point in time. You should different features or ideas in progress at any given
know that Git snapshots are always time – some of which are ready to go, and others
committed to the local repository which are not. Branching exists to help you
manage this workflow
Commit commands : i. When you create a branch in your project, you’re
There are two important commit creating an environment where you can try out
commands new ideas. Changes you make on a branch don’t
1) git add affect the main branch, so you’re free to
Used to save a copy of the current experiment and commit changes
state of the project you make changes j. This is also useful when we have multiple people
with git add working on a project. Each person creates a
2) git commit branch for the feature or bug – fix they are
After you’re satisfied with he made working on and when they are finished they merge
snapshot, you commit it to the project it back into the master branch
history with git commit k. Step (new Git branch)
1. Step 1 : create a new branch with this
following command

git branch [branch-name]

Note* : now we created a new branch called


“test-branch”
2. Step 2 : confirm that we have created a new
branch

git branch
test-branch
* master

Note* : we can see the new branch with the


name “test-branch”, but the * beside master
specifies that we are currently on that branch

3. Step 3 : checkout from a branch. Checkout is


the command used to check out a branch.
Moving us from the current branch, to the one
specified at the end of the command :

git checkout test-branch


Switched to branch ‘test-branch’

Note* : now we have moved our current


workspace from the master branch, to the new
branch. open your favourite editor and make
some changes

4. s
it remote add origin [repository url]

https://www.w3schools.com/git/git_branch.asp
Set up Notepad++ for Git Bash in Windows

- why notepad++
1. Notepad++ is a very simple and easy to
use text editor and used by a good
number of developers in the community
2. There are loads of plugins available for
Notepad++ which can make your tasks
simple
3. Notepad++ which can make your tasks
simple. With the support of many
programming languages to code in,
Notepad++ is very fast while starting up.

- Step
1. Prerequisite : Notepad++ should be
installed on your system. You can
download the same from here. Remember
the directory in which you have installed
the Notepad (notepad++.exe)

https://www.toolsqa.com/git/set-up-
notepad-for-git-bash/ (checkpoint)
2.

You might also like