0% found this document useful (0 votes)
49 views

Installing Git

The document provides information about version control systems and Git. It explains that version control systems allow software teams to track changes to source code over time by taking snapshots of files. Git is introduced as a free, open source distributed version control system that stores snapshots to allow reverting to previous versions if needed. Key features of Git like distributed architecture and performance, security and flexibility are described. Steps for installing, initializing, adding, committing and checking the status of files in Git repositories are outlined. The relationship between Git and GitHub is explained, with GitHub described as a hosting service for Git repositories that enables collaboration.

Uploaded by

Yesmine Makkes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Installing Git

The document provides information about version control systems and Git. It explains that version control systems allow software teams to track changes to source code over time by taking snapshots of files. Git is introduced as a free, open source distributed version control system that stores snapshots to allow reverting to previous versions if needed. Key features of Git like distributed architecture and performance, security and flexibility are described. Steps for installing, initializing, adding, committing and checking the status of files in Git repositories are outlined. The relationship between Git and GitHub is explained, with GitHub described as a hosting service for Git repositories that enables collaboration.

Uploaded by

Yesmine Makkes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 7

L extention de repostory hiya git

VCS Version control systems are a category of software tools that help a software team manage
changes to source code over time.
As you edit to your code, you tell the version control system to take a snapshot of your files.
The version control system saves that snapshot permanently so you can recall it later if you need it.
Without version control, you’re tempted to keep multiple copies of code on your computer. This is
dangerous because it’s easy to change or delete a file in the wrong copy of code, potentially losing
work.
Version control systems solve this problem by managing all versions of your code but presenting
you with a single version at a time.
If you google "what is git", you will probably see the definition for "an unpleasant or contemptible
person."
Thankfully, Git is much better than that. According to the Git documentation:
Git is a free and open source distributed VCS designed to handle everything from small to very
large projects with speed and efficiency.
In plain English, Git is a tool that allows developers to track versions of their code over time. It
does this by creating "snapshots" of the current state of the code base whenever you tell it to.
Git is essential when collaborating with other developers to ensure that previous "snapshots" of the
code can be revisited if necessary.
For example, if you are working on the code and accidentally break the app, it's much easier if
you're using Git and can simply roll back to a previous version of the code.

Having a distributed architecture, Git is an example of a DVCS (hence Distributed Version Control
System). Rather than have only one single place for the full version history of the software as is
common in once-popular version control systems like CVS or Subversion (also known as SVN), in
Git, every developer's working copy of the code is also a repository that can contain the full history
of all changes. In addition to being distributed, Git has been designed with performance
, security and flexibility in mind.

Installing Git
Git isn’t usually set up by default on your computer, so you need to install and configure it before
you can start using it to manage your code.
It’s important to keep Git up to date, just like all the other software on your machine. Updates
protect you from security vulnerabilities, fix bugs, and give you access to new features.
The recommended method of installing and maintaining Git is provided for three major platforms
below :

Start using Git


Once we have Git installed, we need to "initialize" a repository with Git before we can start using it.
To do so, it's very easy just follow my lead:
1. Access the wanted folder using the terminal (prompt cmd)
2. To initialize a repository we have only to run:

heck the Status of Your Repository


Now that we have some files in our repository, let's see how Git treats them.
To check the current status of your repository, we use the git status command.

Adding and committing Files


Remember that folder we create, now we are going to use it, let’s make file inside it?
Feel free to add whatever you want !

Check the Status of Your Repository


Now that we have some files in our repository, let's see how Git treats them.
To check the current status of your repository, we use the git status command.
git status

The output would be :

Adding Files for Git to Track


At this point, we do not have any files for Git to track.
We need to add files specifically to Git order to tell Git to track them. We add files using add.
After running git add . Git will add all the repository files to to an intermidate area called the
staging area. We can also add only what we want simply by running git add myFileName

Adding and committing Files


Remember that folder we create, now we are going to use it, let’s make file inside it?
Feel free to add whatever you want !

Check the Status of Your Repository


Now that we have some files in our repository, let's see how Git treats them.
To check the current status of your repository, we use the git status command.
git status

The output would be :


Adding Files for Git to Track
At this point, we do not have any files for Git to track.
We need to add files specifically to Git order to tell Git to track them. We add files using add.
After running git add . Git will add all the repository files to to an intermidate area called the
staging area. We can also add only what we want simply by running git add myFileName
git add .

The output would be :

Removing Files
Let’s say that you have added files to Git and you do not want it to track.
In such a situation, you tell Git to stop tracking them.
Yet, running a simple git rm will not only remove it from Git, but will also remove it from your
local file system as well! To tell Git to stop tracking a file, but still keep it on your local system, run
the following command:

Adding and committing Files


Remember that folder we create, now we are going to use it, let’s make file inside it?
Feel free to add whatever you want !

Check the Status of Your Repository


Now that we have some files in our repository, let's see how Git treats them.
To check the current status of your repository, we use the git status command.
git status

The output would be :

Adding Files for Git to Track


At this point, we do not have any files for Git to track.
We need to add files specifically to Git order to tell Git to track them. We add files using add.
After running git add . Git will add all the repository files to to an intermidate area called the
staging area. We can also add only what we want simply by running git add myFileName
git add .

Removing Files
Let’s say that you have added files to Git and you do not want it to track.
In such a situation, you tell Git to stop tracking them.
Yet, running a simple git rm will not only remove it from Git, but will also remove it from your
local file system as well! To tell Git to stop tracking a file, but still keep it on your local system, run
the following command:
git rm --cached [file_name]

Committing Changes
Once you have staged your files, you can commit them into Git.
Imagine a commit as a snapshot in time where you can return back to access your repository at that
stage. You associate a commit message with every commit, which you can provide with the -m
prefix.
git commit -m 'first commit'

Files status
Git sees every file in your working copy as one of three things:
Tracked
A file which has been previously staged or committed.
Untracked
A file which has not been staged or committed.
Ignored
A file which Git has been explicitly told to ignore.
Ignored files are usually build artifacts and machine generated files that can be derived from your
repository source or should otherwise not be committed
*PS : If we have some file that we do not want them to be tracked, we just put it inside
.gitignore file.

Configuration settings
The .gitconfig file contain a list of configuration that affect the behaviour of git command, so
in order to manipulate it, we use the command git config <configuration> , so to
change the name and email used by git to identify the user we use the following command (PS.
change YOUR.NAME and YOUR.EMAIL with your own values.)
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL"

Many times you may be finding yourself typing git commands over and over. Things like git
add, git init and git status are commands you will be typing many times, so it may be
useful to make a shortcut, or alias, which you can type so that you do not need to type the entire
command. To create a temporary alias, which will last as long as your terminal session is open, you
can type:
git config alias.KEYBOARD_SHORTCUT COMMAND
So if we wanted to type git st and have that be the same as git status we would type git
config alias.st status. Now we can type git st and it should output the same as git
status.

If you would like your alias to be a part of your global configuration, add the --global
command after git config. For example, to alias git i to git init globally, you would
type git config --global alias.i init.

git config alias.i init

Set an alias for init

git config --global user.email "YOUR EMAIL"

Set the user email to whatever you want

GitHub is a web-based Git repository hosting service.


Simply put, it is a tool that enables collaboration by hosting
shared Git repositories that teams of developers can all
contribute to.
While GitHub uses Git, the functionality it provides is VERY
different from Git so make sure you understand that Git and GitHub
are not the same thing.

In short, Git is a Version Control System. GitHub is an online platform for hosting and sharing
code, text files and even more complex file forma
GitHub provide a great way for you to store your code in a remote
location (in case something happens to your local machine). It's a
fantastic way to collaborate with other developers both privately
and publicly.
Many large open source projects are hosted on GitHub, which makes
it very easy to examine the code both on GitHub and locally.
In the next couple of chapters, we will learn how to move code
from our local repository to a remote repository on GitHub using
the push command, as well as retrieve code from a remote
repository on GitHub using the pull command.
We'll also learn about GitHub specific concepts like forking and
pull requests.

Want to get a sense for how pervasive GitHub is in the development community? Here are some
projects you may have heard of that are hosted there:
If you don't have an account with GitHub yet, head to github.com and create an
account. Signing up is easy!
Be sure to use whatever email address is in your .gitconfig for your email
address when you sign up with GitHub.
If you'd rather sign up with a different email address, change your .gitconfig
accordingly. You'll run into some minor annoyances if there's a mismatch between
the email address in your GitHub profile and the email address in your
.gitconfig.

GitHub

is a for-profit company that offers a cloud-based


Git
repository hosting service. Essentially, it makes it a lot easier for individuals and teams to use Git
for
version control
and
collaboration
. GitHub’s interface is user-friendly enough so even novice coders can take advantage of Git.
Without GitHub
, using Git generally requires a bit more technical savvy and use of the command line.

Pushing code up to GitHub


Now after creating a repository in GitHub, we need to add our local code (after commits) to the
remote repo. It’s very simple first we need to attach the address of the GitHub repo to our local
project, simply by running git remote add origin YOUR_REPO_URL
Now after providing the remote URL to the local repository, to
take the local files to tada our files are now in github.he
remote, we have to run this command git push origin master

Now that we know how to push code up to GitHub, let's discuss a


GitHub specific concept: forking.
When working with others, you may sometimes not be able to push directly to that repository
(imagine if we could just push our code to some of the world's largest open source projects...that
would be pretty crazy).
So what we need to do is make a copy of someone else's remote repository and make sure it is
under our username so that we can push code to it.
To practice forking - head over to any repo on github and on the top right you will see a button with
the text Fork. Click on this button and you will have a copy of the repository under your name!
Remember, the "forking" is a GitHub concept, and not something directly related to Git. It is
simply the way to make your own copy of a repository on your account where you have permission
to push your code to GitHub.
Once you have forked the repository, you need to take that
repository (the remote one you just made) and download the code on
your local computer (make a local repository). Instead of making a
folder and going through the whole git init process and adding a
remote, you can use the git clone command, which accepts a link to
the repository and downloads it into a folder (with git and a
remote already set up!)
Now to do so, first click on the button clone, it will provide us a remote url just copy it.
In terminal just run git clone THE_COPYED_ADDRESS
Now let's say you are collaborating with an organization on github
(where you forked the repository from) and you would like to merge
your changes with the original repo that you forked (remember you
can't just push up to it, because you do not have permission to do
that). You can issue a pull request and someone who has permission
can either merge or reject it.
To do this, click on the "New pull request button" and then click on the "Create pull request". You
should then be able to go to the original repository and see your pull request or "PR".
A
fork
is a copy of a
repository
. Forking a repository allows you to freely experiment with
changes
without affecting the original project. After making some changes and you want to contribute to the
project all you have to do is a
pull
request where you send the proposed changes to the owner of the project and after review it. He can
merge
it to the master

You might also like