{"id":12726,"date":"2019-03-28T14:53:26","date_gmt":"2019-03-28T14:53:26","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12726"},"modified":"2019-03-28T14:53:26","modified_gmt":"2019-03-28T14:53:26","slug":"install-git-to-create-and-share-your-own-projects-on-github-repository","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/install-git-to-create-and-share-your-own-projects-on-github-repository\/","title":{"rendered":"Install GIT to Create and Share Your Own Projects on GITHub Repository"},"content":{"rendered":"<p>If you have spent any amount of time recently in the\u00a0<strong>Linux<\/strong>\u00a0world, then chances are that you have heard of\u00a0<strong>GIT<\/strong>.\u00a0<strong>GIT<\/strong>\u00a0is a distributed version control system that was created by\u00a0<strong>Linus Torvalds<\/strong>, the mastermind of\u00a0<strong>Linux<\/strong>\u00a0itself. It was designed to be a superior version control system to those that were readily available, the two most common of these being\u00a0<strong>CVS<\/strong>\u00a0and\u00a0<a title=\"Create SVN in Linux\" href=\"https:\/\/www.tecmint.com\/install-svn-subversion-1-7-server-using-ubersvn-12-4-on-redhatcentos-5-2\/\" target=\"_blank\" rel=\"noopener\">Subversion (SVN)<\/a>.<\/p>\n<p>Whereas\u00a0<strong>CVS<\/strong>\u00a0and\u00a0<strong>SVN<\/strong>\u00a0use the\u00a0<strong>Client<\/strong>\/<strong>Server<\/strong>\u00a0model for their systems,\u00a0<strong>GIT<\/strong>\u00a0operates a little differently. Instead of downloading a project, making changes, and uploading it back to the server,\u00a0<strong>GIT<\/strong>\u00a0makes the local machine act as a server.<\/p>\n<div id=\"attachment_4585\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Install-GitHub.jpeg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4585\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Install-GitHub.jpeg\" alt=\"Install GitHub in Centos\" width=\"600\" height=\"400\" aria-describedby=\"caption-attachment-4585\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-4585\" class=\"wp-caption-text\">Install GitHub Repository<\/p>\n<\/div>\n<p>In other words, you download the project with everything, the source files, version changes, and individual file changes right to the local machine, when you check-in, check-out, and perform all of the other version control activities. Once you are finished, you then merge the project back to the repository.<\/p>\n<p>This model provides many advantages, the most obvious being that if you are disconnected from your central server for whatever reason, you still have access to your project.<\/p>\n<p>In this tutorial, we are going to\u00a0<strong>install GIT<\/strong>,\u00a0<strong>create a repository<\/strong>, and\u00a0<strong>upload that repository<\/strong>\u00a0to\u00a0<strong>GitHub<\/strong>. You will need to go to\u00a0<a href=\"https:\/\/www.github.com\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.github.com<\/a>\u00a0and\u00a0<strong>create an account<\/strong>\u00a0and\u00a0<strong>repository<\/strong>\u00a0if you wish to upload your project there.<\/p>\n<h3>How to Install GIT in Linux<\/h3>\n<p>On\u00a0<strong>Debian<\/strong>\/<strong>Ubuntu<\/strong>\/<strong>Linux Mint<\/strong>, if it is not already installed, you can install it using\u00a0<strong>apt-get<\/strong>\u00a0command.<\/p>\n<pre>$ sudo apt-get install git<\/pre>\n<p>On\u00a0<strong>Red Hat<\/strong>\/<strong>CentOS<\/strong>\/<strong>Fedora<\/strong>\/ systems, you can install it using\u00a0<strong>yum<\/strong>\u00a0command.<\/p>\n<pre>$ yum install git<\/pre>\n<p>If you prefer to install and compile it form source, you can follow below commands.<\/p>\n<pre>$ wget http:\/\/kernel.org\/pub\/software\/scm\/git\/git-1.8.4.tar.bz2\r\n$ tar xvjf git-1.8.4.tar\/bz2\r\n$ cd git-*\r\n$ .\/configure\r\n$ make\r\n$ make install<\/pre>\n<h3>How to Create Git Project<\/h3>\n<p>Now that\u00a0<strong>GIT<\/strong>\u00a0is installed, let\u2019s set it up. In your\u00a0<strong>home<\/strong>\u00a0directory, there will be a file called \u201c<strong>~\/.gitconfig<\/strong>\u201c. This holds all of your repository info. Let\u2019s give it\u00a0<strong>your name<\/strong>\u00a0and\u00a0<strong>your email<\/strong>:<\/p>\n<pre>$ git config \u2013-global user.name \u201cYour Name\u201d\r\n$ git config \u2013-global user.email youremail@mailsite.com<\/pre>\n<p>Now we are going to\u00a0<strong>create our first repository<\/strong>. You can make any directory a\u00a0<strong>GIT repository<\/strong>. cd to one that has some source files and do the following:<\/p>\n<pre>$ cd \/home\/rk\/python-web-scraper\r\n$ git init<\/pre>\n<p>In that directory, a new hidden directory has been created called \u201c<strong>.git<\/strong>\u201c. This directory is where\u00a0<strong>GIT<\/strong>\u00a0stores all of its information about your project, and any changes that you make to it. If at any time you no longer wish for any directory to be a part of a\u00a0<strong>GIT<\/strong>\u00a0repository, you just delete this directory in the typical fashion:<\/p>\n<pre>$ rm \u2013rf .git<\/pre>\n<p>Now that we have a repository created, we need to\u00a0<strong>add some files to the project<\/strong>. You can add any type of file to your\u00a0<strong>GIT<\/strong>\u00a0project, but for now, let\u2019s generate a \u201c<strong>README.md<\/strong>\u201d file that gives a little info about your project (also shows up in the\u00a0<strong>README<\/strong>\u00a0block at\u00a0<strong>GitHub<\/strong>) and add some source files.<\/p>\n<pre>$ vi README.md<\/pre>\n<p>Enter in info about your project, save and exit.<\/p>\n<pre>$ git add README.md\r\n$ git add *.py<\/pre>\n<p>With the two above commands, we have added the \u201c<strong>README.md<\/strong>\u201d file to your\u00a0<strong>GIT<\/strong>\u00a0project, and then we added all\u00a0<strong>Python<\/strong>\u00a0source\u00a0<strong>(*.py)<\/strong>\u00a0files in the current directory. Worth noting is that\u00a0<strong>99<\/strong>\u00a0times out of\u00a0<strong>100<\/strong>\u00a0when you are working on a\u00a0<strong>GIT<\/strong>\u00a0project, you are going to be adding all of the files in the directory. You can do so like this:<\/p>\n<pre>$ git add .<\/pre>\n<p>Now we are ready to commit the project to a stage, meaning that this is a marker point in the project. You do this with the git commit \u201c<strong>\u2013m<\/strong>\u201d command where the \u201c<strong>\u2013m<\/strong>\u201d option specifies a message you want to give it. Since this is out first commit of out project, we will enter in \u201c<strong>first commit<\/strong>\u201d as our \u201c<strong>\u2013m<\/strong>\u201d string.<\/p>\n<pre>$ git commit \u2013m \u2018first commit\u2019<\/pre>\n<h3>How to Upload Project to GitHub Repository<\/h3>\n<p>We are now ready to push your project up to\u00a0<strong>GitHub<\/strong>. You will need the\u00a0<strong>login information<\/strong>\u00a0that you made when you created your account. We are going to take this information and pass it to\u00a0<strong>GIT<\/strong>\u00a0so it knows where to go. Obviously, you\u2019ll want to replace \u2018<strong>user<\/strong>\u2019 and \u2018<strong>repo.git\u2019<\/strong>\u00a0with the proper values.<\/p>\n<pre>$ git remote set-url origin git@github.com:user\/repo.git<\/pre>\n<p>Now, it is time to push, ie copy from your repository to the remote repository. The git push command takes two arguments: the \u201c<strong>remotename<\/strong>\u201d and the \u201c<strong>branchname<\/strong>\u201d. These two names are usually origin and master, respectively:<\/p>\n<pre>$ git push origin master<\/pre>\n<p>That\u2019s it! Now you can go the\u00a0<a href=\"https:\/\/github.com\/username\/repo\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/github.com\/username\/repo<\/a>\u00a0link to see your own git project.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/install-git-to-create-and-share-your-own-projects-on-github-repository\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have spent any amount of time recently in the\u00a0Linux\u00a0world, then chances are that you have heard of\u00a0GIT.\u00a0GIT\u00a0is a distributed version control system that was created by\u00a0Linus Torvalds, the mastermind of\u00a0Linux\u00a0itself. It was designed to be a superior version control system to those that were readily available, the two most common of these being\u00a0CVS\u00a0and\u00a0Subversion &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/install-git-to-create-and-share-your-own-projects-on-github-repository\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install GIT to Create and Share Your Own Projects on GITHub Repository&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12726","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12726"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12726\/revisions"}],"predecessor-version":[{"id":12727,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12726\/revisions\/12727"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}