{"id":108,"date":"2024-01-05T03:50:57","date_gmt":"2024-01-05T03:50:57","guid":{"rendered":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/?p=108"},"modified":"2024-01-05T04:03:38","modified_gmt":"2024-01-05T04:03:38","slug":"getting-started-with-github","status":"publish","type":"post","link":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/?p=108","title":{"rendered":"Getting started with GitHub"},"content":{"rendered":"\n<p>GitHub is a web-based platform that enables users to manage and collaborate on code repositories. Today, we will talk about using GitHub and how to get started. Let\u2019s look at the following topics:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Adding an SSH key to GitHub<\/li>\n\n\n\n<li>Configuring your Git username and email<\/li>\n\n\n\n<li>Initializing (or Cloning) a Git repository<\/li>\n<\/ol>\n\n\n\n<p>Let\u2019s get started!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding an SSH Key to GitHub<\/h2>\n\n\n\n<p>The first step in working with GitHub is to add an SSH key to your account. This key will allow you to securely connect to the GitHub servers without entering your username and password every time.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open your terminal and navigate to the directory where your SSH key is stored. For example, the key may be located at \/home\/username\/.ssh\/id_rsa.pub.<\/li>\n\n\n\n<li>Copy the contents of the key file, for example, after running the command&nbsp;<code>cat \/home\/username\/.ssh\/id_rsa.pub<\/code>.<\/li>\n\n\n\n<li>Log in to your GitHub account and go to the Settings page. From there, click on \u201cSSH and GPG keys\u201d on the left-hand side.<\/li>\n\n\n\n<li>Click on the \u201cNew SSH key\u201d button and give your key a title (e.g. \u201cMy SSH key\u201d). Paste the contents of your key file into the \u201cKey\u201d field and click \u201cAdd SSH key\u201d.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring Your Git Username and Email<\/h2>\n\n\n\n<p>The final step is to configure your Git username and email. This information is used to identify the author of each commit. Here\u2019s how to configure your Git username and email:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open your terminal and run the command&nbsp;<code>git config --global user.name USERNAME<\/code>. Replace \u201cUSERNAME\u201d with your username.<\/li>\n\n\n\n<li>Run the command&nbsp;<code>git config --global user.email youremail@domain.com<\/code>. Replace \u201cyouremail@domain.com\u201d with your email address that you have used to create your GitHub account.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Initializing (or Cloning) a Git Repository<\/h2>\n\n\n\n<p>The next step is to initialize a Git repository on your local machine. A Git repository is a place where you store and manage your code. Here\u2019s how to initialize a Git repository:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><em>Option-1: Create a new Git repository<\/em><\/strong>.<br>Open your terminal and navigate to the directory where you want to create your repository. Run the command&nbsp;<code>git init<\/code>. This will create a new Git repository in the current directory.<br><strong><em>Option-2: Clone a Git repository<\/em><\/strong><br>Let\u2019s assume that you have forked a repository on your GitHub account. Open your terminal and navigate to the directory where you want to clone the repository locally. Type&nbsp;<code>git clone git@github.com:username\/repository.git<\/code><br>You can check the content by typing&nbsp;<code>cd repository<\/code>. You can get the exact address of the repository by clicking the&nbsp;<code>&lt;&gt;Code<\/code>&nbsp;tab on the repository\u2019s page.<\/li>\n\n\n\n<li>Suppose you have created a file in this repository directory; you can add your files to the repository by running the command&nbsp;<code>git add .<\/code>&nbsp;to add all files in the current directory to the repository. You can also add a single file using the command&nbsp;<code>git add filename<\/code><\/li>\n\n\n\n<li>Commit your changes by running the command&nbsp;<code>git commit -m \"Some comments for your commit\"<\/code>. This will create a new commit with a message.<\/li>\n<\/ol>\n\n\n\n<p>And there you have it! You now know how to add an SSH key to GitHub, configure your Git username and email, and initialize\/clone a Git repository. With these basics in place, you\u2019re ready to start managing your code on GitHub.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GitHub is a web-based platform that enables users to manage and collaborate on code repositories. Today, we will talk about using GitHub and how to get started. Let\u2019s look at the following topics: Let\u2019s get started! Adding an SSH Key to GitHub The first step in working with GitHub is to add an SSH key [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"off","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[10,12,5],"tags":[],"class_list":["post-108","post","type-post","status-publish","format-standard","hentry","category-codemanagement","category-github","category-programmerlife"],"_links":{"self":[{"href":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/index.php?rest_route=\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=108"}],"version-history":[{"count":2,"href":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/index.php?rest_route=\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":118,"href":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/index.php?rest_route=\/wp\/v2\/posts\/108\/revisions\/118"}],"wp:attachment":[{"href":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tifrh.res.in\/~ramakrishnan\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}