Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 2 months ago

What exactly is Git?

I am remotely familiar with GitHub, where developers share their coding online (I think?) but I am completely confused as to what Git is, and what the purpose of it is. It looks like a file managing command prompt, but I don't get what it is and why I will need it someday. Could someone briefly enlighten a newbie? Thanks!

2 Answers

Relevance
  • oyubir
    Lv 6
    2 months ago
    Favorite Answer

    1. Git IS NOT the commandline to access github.

    Git is far older than github.

    Github is a centralized repository made to work with git. That is a more than important nuance.

    2. Git is a versioning system.

    You can describe git in several levels.

    2a.

    It first level is completely standalone, server less, team less, communication less, etc. tool.

    It is just a local tool that you can use for yourself alone, to keep track of modification you make on your code. Locally.

    So you have a folder "MyCode" on your own computer. That you have created yourself.

    And in that folder, you have some files. Like "main.c" and "other.py".

    You modify those files, because, well, you are coding.

    And, say, one day, you realize that you have introduced a new bug, and would like to explore older version of your code.

    You can't basically.

    Unless you keep an history of all your code version.

    Which you could do using simply frequent backups of your files everyday. So that you can go back to yesterday, or last week, or last month... version.

    But that is not sufficient. What if you made several modification the same day?

    What if your folder is huge and don't want to copy everything everyday ?

    Plus, how to keep easily track of modifications (why you have modified this file. What other files you have modified).

    So, for that, it would be convenient to have a tool to keep a history of all files version. With description of modifications.

    That is the most basic usage of git. It is just a tool, like cp or diff. That you use locally on your files.

    Basic usage is

    git init (once for all, in a repository).

    And then, each time you made a modification

    git commit -m "reason" -a

    Then other git commands allow you to see a history of modifications (git log), see differences between versions (git diff), go back to older versions. Working on different branches. Etc.

    2b.

    All that was developped by Linus for his own, standalone, dev of linux.

    But after a while it became necessary to add team working to that.

    Like CVS or SVN does (those are also versioning system. But more complex. They are not just local tool to work on you local files. But are meant to be use by a team of developpers around a centralized repository).

    Git had another approach. It kept its completely local behaviour.

    But allowed to create another copy of a git managed repository (git clone).

    Even that, is just a copy (like with cp). But if you couple that with a way to access a remove directory (scp, or http, ...) then, you can copy with git clone a copy that is elsewhere.

    And more importantly, your can push and pull modifications (if you "push" modification that you have commited in your local directory, the same modification are made on the remote copy from which you got your clone. If you "pull", new modification on the remote copy -- for example modification that someone else have pushed -- are added to your local directory).

    So, that second layer (clone, push, pull) allows git to synchronize copies of the same code, present in several persons  computers.

    (Not necessarily in a server/client architecture. It could be peer 2 peer. But 99.999999% of the time, it is how people use it. With a centralized repository on which nobody directly works, but that people clone, pull, and push onto)

    So, those 2 layers together, plus the habit to have a centralized place where to clone and pull from, and where to push to, make git very similar to cvs or svn

    2c.

    The last layer of all that, is that some companies created open repositories where anybody can create a directory for a projet, to clone and pull from and push to.

    github is one of them.

    So it is a mistake to see git as a commandline to access an internet service (even more one particular one).

    Git is essentialy a local file handling tool. Barely more clever than unix tools such as diff, patch, grep, etc.

    That you can choose to use on copies of codes copied from a machine to another with scp or http.

    Seeing git as a tool to access github make it seems more complicated than it is.

    And would be like saying that vlc is a commandline software to access youtube. It is not. Not at all. First of all youtube is just one particular server hosting videos. Vlc preexisted it, and is not related to that one particular commercial service. Second of all, vlc is essentially just a video player, working on local file, to which was added the capability to fetch videos remotely.

    github is just one particular server hosting directories of versionned code. Git preexisted it and is not related to that particular service. And any way, git is essential just a tool to keep track local modification to local files, to which was added capabilities to fetch directories and modifications remotely.

    tl;dr

    git is a tool to keep history of versions of some files. With capabilites to push and pull modifications to remote clone of those files.

    github is a commercial service to host repositories of code, that understand git push/pull/clone commands (and provides some fancy web interface to explore hosted versions without need for a git client)

  • 2 months ago

    Git is command-line client software to access GitHub.

    There are UI interfaces to it but it still uses Git in the background to actually do the work of pushing and pulling code to and from the repository.

Still have questions? Get your answers by asking now.