Git: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
No edit summary
(Wrote article on Git)
Line 1: Line 1:
'''Git''' is an open source [[Version Control System]] made by Linus Torvalds in 2005. It is one of the most well known and popular among version control systems.
{{stub}}


== Information ==
'''Git''' is a [[Version Control System]] made by Linus Torvalds in 2005. It is one of the most well known and popular among version control systems.
Oftentimes when working on a hobby operating system, files end up being lost or broken, and having a backup of an older version is useful. Git (not to be confused with [[Github|GitHub]]) is a [[Version Control System]], which can be used to push backups of a version of a project (known as a repository, or "repo") to a remote server. This can be a private repository, or a public repository to share work with other developers, in the case of many [https://en.wikipedia.org/wiki/Open-source_software open source] projects.

== Features ==
Oftentimes these repositories will include a file called a README, which includes information about the project structure and goals. Git also supports pull requests, which make it easier for multiple people to work on a repository together by publishing an issue as well as a fork of the repository with their changes. Git also supports branches, which is a pointer to a snapshot of a change, and forks, which are a way for users of Git to make their own copy of a repository. Users can also merge forks of a repository together.

== History ==
Git was initially developed in 2005 by [https://en.wikipedia.org/wiki/Linus_Torvalds Linus Torvalds] as a side project to help him develop the [[Linux]] kernel, as a replacement for another closed source Version Control System that he was using at the time, [https://en.wikipedia.org/wiki/BitKeeper BitKeeper], after Linux was revoked access to the service. On the 26th of July, 2005, Torvalds turned over Git's maintenance to [https://simple.wikipedia.org/wiki/Junio_Hamano Junio Hamano].

== Git vs. GitHub ==
[https://github.com GitHub], a closed source website owned by Microsoft, owns remote servers powered by the Git, allowing developers to host their remote repositories on GitHub's servers rather than their own. While closed source, GitHub has had a massive impact on the open source community that should still be recognised. GitHub also provides a web interface to browse files of a repository.

It's a common mistake for developers new to Git (and programming in general) to not understand the difference between Git and GitHub, however the difference should be recognised.

== Usage ==
While a full tutorial would not fit this wiki, there's four simple commands that every developer should know when using Git. Before trying any of these commands, you must first install Git from the [https://git-scm.com/ official website]. This may already be installed on some Linux distributions.

Firstly, cloning a repository, which is basically downloading a remote repository to your own machine. To do so, run the following command in your terminal:<syntaxhighlight lang="bash">
git clone [URL of repository]
</syntaxhighlight>To push updates made from a local machine to a remote repository, there are three commands needed. You must be in the directory of the project to run these. Firstly, you must stage all changes made to the repository:<syntaxhighlight>
git add .
</syntaxhighlight>Now, you can make a commit message, which is a short single-line comment on the changes made. Often repositories will have a specific structure for commit messages that you must adhere to. To do so, run:<syntaxhighlight>
git commit -m "[COMMIT MESSAGE]"
</syntaxhighlight>Finally, push the updates to the remote repository:<syntaxhighlight>
git push
</syntaxhighlight>Note that these instructions expect that you created the repository. There will be additional steps such as forking the repository and making a pull request when you are contributing to somebody else's repository. This also expects that you are pushing to the main branch.


== See also ==
== See also ==
* [https://en.wikipedia.org/wiki/Git Wikipedia Article on Git]
* [https://en.wikipedia.org/wiki/Git Wikipedia Article on Git]
* [https://git-scm.com/ Git Homepage]
* [https://en.wikipedia.org/wiki/Linus_Torvalds Wikipedia Article on Linus Torvalds]


[[Category:Tools]]
[[Category:Tools]]

Revision as of 23:57, 27 June 2024

Git is an open source Version Control System made by Linus Torvalds in 2005. It is one of the most well known and popular among version control systems.

Information

Oftentimes when working on a hobby operating system, files end up being lost or broken, and having a backup of an older version is useful. Git (not to be confused with GitHub) is a Version Control System, which can be used to push backups of a version of a project (known as a repository, or "repo") to a remote server. This can be a private repository, or a public repository to share work with other developers, in the case of many open source projects.

Features

Oftentimes these repositories will include a file called a README, which includes information about the project structure and goals. Git also supports pull requests, which make it easier for multiple people to work on a repository together by publishing an issue as well as a fork of the repository with their changes. Git also supports branches, which is a pointer to a snapshot of a change, and forks, which are a way for users of Git to make their own copy of a repository. Users can also merge forks of a repository together.

History

Git was initially developed in 2005 by Linus Torvalds as a side project to help him develop the Linux kernel, as a replacement for another closed source Version Control System that he was using at the time, BitKeeper, after Linux was revoked access to the service. On the 26th of July, 2005, Torvalds turned over Git's maintenance to Junio Hamano.

Git vs. GitHub

GitHub, a closed source website owned by Microsoft, owns remote servers powered by the Git, allowing developers to host their remote repositories on GitHub's servers rather than their own. While closed source, GitHub has had a massive impact on the open source community that should still be recognised. GitHub also provides a web interface to browse files of a repository.

It's a common mistake for developers new to Git (and programming in general) to not understand the difference between Git and GitHub, however the difference should be recognised.

Usage

While a full tutorial would not fit this wiki, there's four simple commands that every developer should know when using Git. Before trying any of these commands, you must first install Git from the official website. This may already be installed on some Linux distributions.

Firstly, cloning a repository, which is basically downloading a remote repository to your own machine. To do so, run the following command in your terminal:

git clone [URL of repository]

To push updates made from a local machine to a remote repository, there are three commands needed. You must be in the directory of the project to run these. Firstly, you must stage all changes made to the repository:

git add .

Now, you can make a commit message, which is a short single-line comment on the changes made. Often repositories will have a specific structure for commit messages that you must adhere to. To do so, run:

git commit -m "[COMMIT MESSAGE]"

Finally, push the updates to the remote repository:

git push

Note that these instructions expect that you created the repository. There will be additional steps such as forking the repository and making a pull request when you are contributing to somebody else's repository. This also expects that you are pushing to the main branch.

See also