{"id":59615,"date":"2018-09-05T15:00:51","date_gmt":"2018-09-05T12:00:51","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=59615"},"modified":"2022-07-29T17:56:16","modified_gmt":"2022-07-29T14:56:16","slug":"git-tutorial-for-beginners","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/","title":{"rendered":"Git Tutorial for Beginners"},"content":{"rendered":"<h2 class=\"wp-block-heading\" id=\"h-1-git-what\"><a name=\"git-what\"><\/a>1. Git What?<\/h2>\n<p>Welcome to the Git Tutorial for Beginners. What is Git? Git is a free and open source distributed version control system. It was originally developed by Linus Torvalds, the creator of the Linux operating system. Git is fast and can handle projects of different sizes. If you have a software project, chances are you will rely on Git for version control.<\/p>\n<p>You can also check this tutorial in the following video:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.youtube.com\/watch?v=sCcRmzZFmLs\"><img decoding=\"async\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/07\/Learning-to-Use-GitHub-1024x576.jpg\" alt=\"\" class=\"wp-image-114562\" width=\"512\" height=\"288\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/07\/Learning-to-Use-GitHub-1024x576.jpg 1024w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/07\/Learning-to-Use-GitHub-300x169.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/07\/Learning-to-Use-GitHub-768x432.jpg 768w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/07\/Learning-to-Use-GitHub.jpg 1280w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><figcaption>Learning to Use GitHub \u2013 Video<br \/><\/figcaption><\/figure>\n<\/div>\n<div class=\"toc\">\n<h3>Table Of Contents<\/h3>\n<dl>\n<dt><a href=\"#git-what\">1. Git what?<\/a><\/dt>\n<dt><a href=\"#starting\">2. Starting a Fresh Repository<\/a><\/dt>\n<dt><a href=\"#repo-config\">3. Repository Configuration<\/a><\/dt>\n<dt><a href=\"#tracking\">4. Tracking your File<\/a><\/dt>\n<dt><a href=\"#cloning\">5. Cloning a Repository<\/a><\/dt>\n<dt><a href=\"#modify\">6. Modify the README.md file<\/a><\/dt>\n<dt><a href=\"#check-log\">7. Check the Log<\/a><\/dt>\n<dt><a href=\"#merge\">8. Merge Conflicts<\/a><\/dt>\n<dt><a href=\"#branching\">9. Branching<\/a><\/dt>\n<dt><a href=\"#ignore\">10. Ignoring Files<\/a><\/dt>\n<dt><a href=\"#bisect\">11. Finding When a Bug was Introduced<\/a><\/dt>\n<dt><a href=\"#pull\">12. Merge\/Pull Request<\/a><\/dt>\n<dt><a href=\"#additional\">13. Git Tutorial &#8211; Additional Commands<\/a><\/dt>\n<dt><a href=\"#summary\">14. Git Tutorial for Beginners Summary<\/a><\/dt>\n<\/dl>\n<\/div>\n<p>The example here was tried and tested on a Windows machine. I suggest you download <a href=\"https:\/\/gitforwindows.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Git for Windows<\/a> so that you can follow this tutorial. Follow the Git for Windows installation instructions there. Yes, there are Git <abbr title=\"Graphical user Interface\">GUI<\/abbr> clients out there but in order to learn what the GUI does, we have to go to the command line. You&#8217;ll need to be familiar with the bash shell because Git for Windows emulates the Git bash shell.<\/p>\n<p>Hopefully in this Git Tutorial for Beginners, you&#8217;ll find it easy to learn. I have always learned by doing, so enough talk and let&#8217;s get down and dirty with Git.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-2-starting-a-fresh-repository\"><a name=\"starting\"><\/a>2. Starting a Fresh Repository<\/h2>\n<ol class=\"wp-block-list\">\n<li>Create a directory called &#8220;practice&#8221;.<\/li>\n<li>Create a file in that directory called &#8220;readme.txt&#8221;.<\/li>\n<li>Add the line &#8220;The quick brown fox jumped over the lazy dog.&#8221;.<\/li>\n<li>Save the file and exit.<\/li>\n<li>Right-click on the directory -&gt; Git Bash Here<\/li>\n<li>Initialize the repository: <code>git init<\/code><\/li>\n<li>Check directory structure: <code>ls -ali<\/code><\/li>\n<li>Check the status of files: <code>git status<\/code><\/li>\n<\/ol>\n<p>You should have something like this:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-git-status.jpg\"><img decoding=\"async\" width=\"636\" height=\"630\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-git-status.jpg\" alt=\"Git Tutorial for Beginners - Git Bash\" class=\"wp-image-59973\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-git-status.jpg 636w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-git-status-150x150.jpg 150w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-git-status-300x297.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-git-status-70x70.jpg 70w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/a><figcaption>Git Bash<\/figcaption><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\" id=\"h-3-repository-configuration\"><a name=\"repo-config\"><\/a>3. Repository Configuration<\/h2>\n<p>Still inside the &#8220;practice&#8221; directory.<\/p>\n<ol class=\"wp-block-list\">\n<li>Configure your username: <code>git config user.name \"{your usersname}\"<\/code> (if you have a GitHub\/GitLab\/Bitbucket username, use it here). You can use the option <code>--global<\/code> after <code>git config<\/code> if you want the same configuration across all repositories.<\/li>\n<li>Caching of your password: <code>git config credential.helper cache<\/code>. Cache credentials for an hour: <code>git config credential.helper \"cache --timeout=3600\"<\/code><\/li>\n<\/ol>\n<h2 class=\"wp-block-heading\" id=\"h-4-tracking-your-file\"><a name=\"tracking\"><\/a>4. Tracking your File<\/h2>\n<ol class=\"wp-block-list\">\n<li>Track readme.txt: <code>git add readme.txt<\/code><\/li>\n<li>Tracking multiples files by using fileglobs: <code>git add *.txt<\/code> or <code>git add .<\/code><\/li>\n<li>Check status: <code>git status<\/code>You should see something like this:<span style=\"text-decoration: underline;\"><em>git status<\/em><\/span>\n<pre class=\"brush:bash wrap-lines:false\">   $ git status\nOn branch master\n\nNo commits yet\n\nChanges to be committed:\n  (use \"git rm --cached ...\" to unstage)\n\n        new file:   readme.txt\n<\/pre>\n<\/li>\n<li>Commit the file: <code>git commit -m \"{commit message}\"<\/code> (you commit message should describe the changes made on the file or files).For now just put &#8220;initial commit&#8221; as your commit message.<\/li>\n<li>Check history: <code>git log<\/code>You shsould see something like this:<span style=\"text-decoration: underline;\"><em>git log<\/em><\/span>\n<pre class=\"brush:bash wrap-lines:false\">\t$ git log\ncommit 83076cf08945e39e49efddadfd74e518a794aa63 (HEAD -&gt; master)\nAuthor: username \nDate:   Mon Aug 27 13:46:57 2018 +0100\n\n    initial commit\n<\/pre>\n<\/li>\n<li>Check the status. It should say working tree clean. Congratulations! You now have a Git repository.<\/li>\n<\/ol>\n<h2 class=\"wp-block-heading\" id=\"h-5-cloning-a-repository\"><a name=\"cloning\"><\/a>5. Cloning a Repository<\/h2>\n<p>That&#8217;s all well and good but it is not fun if you are the only one working in your repository. Grab a friend and create a new project in GitHub\/GitLab\/Bitbucket. Follow the instructions in GitHub\/GitLab\/Bitbucket to push the local repository to the remote repository. This example will use GitLab. Inspect the GitLab project and add members to the project.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-gitlab.jpg\"><img decoding=\"async\" width=\"820\" height=\"548\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-gitlab.jpg\" alt=\"Git Tutorial for Beginners - GitLab\" class=\"wp-image-59976\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-gitlab.jpg 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-gitlab-300x200.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/git-tutorial-beginners-gitlab-768x513.jpg 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption>GitLab<\/figcaption><\/figure>\n<\/div>\n<ol class=\"wp-block-list\">\n<li>Let your friend clone the repository using the URL from GitLab: <code>git clone {URL}<\/code>. Git clone will get the entire history of the repository. Use the <code>--depth<\/code> option to get a limited number of revisions: <code>git clone --depth 5 https:\/\/gitlab.com\/...<\/code>You should see something like this when cloning:<span style=\"text-decoration: underline;\"><em>git clone<\/em><\/span>\n<pre class=\"brush:bash wrap-lines:false\">$ git clone https:\/\/gitlab.com\/username\/practice.git\nCloning into 'practice'...\nremote: Enumerating objects: 3, done.\nremote: Counting objects: 100% (3\/3), done.\nremote: Total 3 (delta 0), reused 0 (delta 0)\nUnpacking objects: 100% (3\/3), done.\n<\/pre>\n<\/li>\n<\/ol>\n<h2 class=\"wp-block-heading\" id=\"h-6-modify-the-readme-md-file\"><a name=\"modify\"><\/a>6. Modify the README.md file<\/h2>\n<ol class=\"wp-block-list\">\n<li>Modify the file in turns. You and your friend will modify the file (add, edit or delete text in it).<\/li>\n<li>Add (<code>git add<\/code>) and commit (<code>git commit<\/code>). Don&#8217;t forget the helpful commit message. Do this a couple of times.<\/li>\n<li>Push the changes to the repository: <code>git push<\/code><\/li>\n<li>After the push, the succeeding person will pull the project before editing the file: <code>git pull<\/code><\/li>\n<li>Do this for at least a couple of round to experience the cycle.<\/li>\n<\/ol>\n<h2 class=\"wp-block-heading\" id=\"h-7-check-the-log\"><a name=\"check-log\"><\/a>7. Check the Log<\/h2>\n<p>The commit log should read like a story. Each commit should be a short step that makes sense together. It should have descriptive commit messages. It should be small steps so that commits are just minutes apart. Don&#8217;t start a new step without finishing an old one. Pull frequently so that you are always working on the latest copy of the project. When you take too long between pulls, changes from other people become harder to merge.<\/p>\n<p>Here&#8217;s a real world example of a commit log:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>git log<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted\">commit 91012a0c87d7e711c807af5df2f37c1e1e44d03c (HEAD -&gt; javaee7-jsf22, origin\/javaee7-jsf22)\nAuthor: xxxxxxx \nDate:   Fri May 11 11:05:29 2018 +0100\n\n    trying out @ApplicationSetting\n\ncommit 9ffe695ddc9c4731717808fd543c1d3b04753121\nMerge: e26cae5 cf73c32\nAuthor: xxxxxxx \nDate:   Sun Mar 11 13:35:07 2018 +0100\n\n    Merge remote-tracking branch 'origin\/javaee7-jsf23' into javaee7-jsf22\n\n    Conflicts:\n            pom.xml\n            src\/main\/java\/org\/example\/kickoff\/business\/service\/UserService.java\n\ncommit cf73c32967deae9dce9c57ca00e641bc2bf62da6\nAuthor: xxxxxxxx\nDate:   Sun Mar 11 13:15:52 2018 +0100\n\n    Update after backport\n\ncommit e39df28330caa36d2c6b59f6674cb0742ecc14e0\nAuthor: xxxxxxxx \nDate:   Sun Mar 11 12:47:14 2018 +0100\n\n    Prepare Java EE 8 - JSF 2.3 branch with WF12 and fixed tests\n\ncommit fa5b9e6d9ee8a5958049adc50e212baac35650a7\nAuthor: xxxxxxxx \nDate:   Wed Feb 28 07:35:29 2018 +0100\n\n    Improve authentication and exception handling\n\ncommit 0afdf1d0a492efa81d0d53397be535c2a73d32b3\nAuthor: xxxxxxxx\nDate:   Sun Feb 25 12:19:19 2018 +0100\n\n    Fix faces-config.xml version\n\ncommit e26cae5e206c6404a9df9b12211de7b8e7d3912c\nAuthor: xxxxxxxxx\nDate:   Sun Feb 25 10:42:39 2018 +0100\n<\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-8-merge-conflicts\"><a name=\"merge\"><\/a>8. Merge Conflicts<\/h2>\n<p>Edit README.md simultaneously. Make it as different as possible so that a merge conflict will happen. Commit your changes. Push your changes simultaneously. One of you will succeed and the other will be rejected. For the one that failed to push, do a pull. You will likely have a merge conflict in your README.md.[ulp id=&#8217;pzgfvmZhgslwSymm&#8217;]<\/p>\n<p>It would look something like this:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>git merge<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted\">&lt;&lt;&lt;&lt;&lt;&lt; HEAD\nyour commit\n=======\nsomeone else's commit!\n&gt;&gt;&gt;&gt;&gt;&gt; e26cae5e206c6404a9df9b12211de7b8e7d3912c\n<\/pre>\n<p>Resolve the conflict by editing the file and then git add, commit and push.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-9-branching\"><a name=\"branching\"><\/a>9. Branching<\/h2>\n<p>Repositories usually exist in multiple branches to allow continued support of old releases or to avoid introducing experimental code to a stable branch. Once a feature branch is finished, it should be merged back to the master branch.<\/p>\n<ol class=\"wp-block-list\">\n<li>Create a branch called ComplexVersion: <code>git checkout -b ComplexVersion<\/code><\/li>\n<li>Write your new changes on README.md and make several commits along the way.<\/li>\n<li>Pull to get the latest version of the repository.<\/li>\n<li>Go back to master branch: <code>git checkout master<\/code><\/li>\n<li>Merge your changes: <code>git merge ComplexVersion<\/code><\/li>\n<li>Delete the branch if you want: <code>git branch -d ComplexVersion<\/code><\/li>\n<\/ol>\n<h2 class=\"wp-block-heading\" id=\"h-10-ignoring-files\"><a name=\"ignore\"><\/a>10. Ignoring Files<\/h2>\n<p>There are some files we don&#8217;t want to track. For example, we don&#8217;t want to track <em>.classpath<\/em>, <em>.project<\/em>, <em>*.class<\/em>, etc. We don&#8217;t want these files saved in the repository. To ignore these files, create a &#8220;.gitignore&#8221; file in the directory of your project.<\/p>\n<p>Example .gitignore file:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>.gitignore<\/em><\/span><\/p>\n<pre class=\"wp-block-preformatted\"># Compiled class file\n*.class\n\n# Log file\n*.log\n\n# BlueJ files\n*.ctxt\n\n# Mobile Tools for Java (J2ME)\n.mtj.tmp\/\n\n# Package Files #\n*.jar\n*.war\n*.nar\n*.ear\n*.zip\n*.tar.gz\n*.rar\n\n# virtual machine crash logs, see http:\/\/www.java.com\/en\/download\/help\/error_hotspot.xml\nhs_err_pid*\n\/bin\/\n.classpath\n.project\n<\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-11-finding-when-a-bug-was-introduced\"><a name=\"bisect\"><\/a>11. Finding When a Bug was Introduced<\/h2>\n<p>The <code>git bisect<\/code> command determines the last known good commit, the first known bad commit, and then checkout the commit in the middle. If the commit in the middle is bad, then you know that the bug was introduced before that. If the commit in the middle is good, then the bug was introduced after that. Repeat the process until you find the revision where the bug was introduced.<\/p>\n<ol class=\"wp-block-list\">\n<li><code>git bisect start<\/code>: Start the bisecting session.<\/li>\n<li><code>git bisect bad {commit ID}<\/code>: Tell Git the commit ID where the bug was first detected.<\/li>\n<li><code>git bisect good {commit ID}<\/code>: Tell Git the last known good commit.<\/li>\n<li>Git will checkout the commit between the two commits.<\/li>\n<li>Test the checkedout commit and mark it accordingly (e.g. <code>git bisect bad, git bisect good<\/code>).<\/li>\n<li>Git will then checkout the next appropriate commit until you find where the bug was introduced.<\/li>\n<li><code>git bisect rest<\/code>: All done. Reset back to HEAD.<\/li>\n<\/ol>\n<h2 class=\"wp-block-heading\" id=\"h-12-merge-pull-request\"><a name=\"pull\"><\/a>12. Merge\/Pull Request<\/h2>\n<p>To create a merge request, you need to go to GitLab\/GitHub\/Bitbucket and go pick the branch we want to merge. A merge request is also called a pull request. In the merge request, you&#8217;ll provide a title, description, approvers and most important of all are the source and target branch. Submit your merge request when you are ready and once it is merged by the approver, your changes will be in the target branch.<\/p>\n<p>A merge request looks like the images below:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/merge-request-1.jpg\"><img decoding=\"async\" width=\"820\" height=\"326\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/merge-request-1.jpg\" alt=\"Git Tutorial for Beginners - Merge Request 1\" class=\"wp-image-59974\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/merge-request-1.jpg 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/merge-request-1-300x119.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/merge-request-1-768x305.jpg 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption>Merge Request 1<\/figcaption><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/merge-request-2.jpg\"><img decoding=\"async\" width=\"820\" height=\"419\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/merge-request-2.jpg\" alt=\"Git Tutorial for Beginners - Merge Request 2\" class=\"wp-image-59975\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/merge-request-2.jpg 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/merge-request-2-300x153.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/merge-request-2-768x392.jpg 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption>Merge Request 2<\/figcaption><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\" id=\"h-13-git-tutorial-additional-commands\"><a name=\"additional\"><\/a>13. Git Tutorial &#8211; Additional Commands<\/h2>\n<ol class=\"wp-block-list\">\n<li><code>git commit -am \"improve sort algorithm #99\"<\/code>: Linking GitLab issues using commit messages. Include <code>#{issue number}<\/code> in the commit message.<\/li>\n<li><code>git commit -am \"closes #99. code clean up.\"<\/code>: Close an issue. Other keywords for closing an issue: <code>close, closed, fix, fixes, fixed, resolve, resolves, resolved<\/code>.<\/li>\n<li><code>git checkout -- README.md<\/code>: Revert to version last committed.<\/li>\n<li><code>git reset HEAD README.md<\/code>: Unstage a file (i.e. you don&#8217;t want to commit a file).<\/li>\n<li><code>git commit --amend<\/code>: Amending a commit.<\/li>\n<li><code>git reset --hard HEAD<\/code>: Bin all project changes. This is dangerous!<\/li>\n<li><code>git reset --hard {commit id}<\/code>: Revert a project to a previous commit.<\/li>\n<li><code>git mv README.md README2.md<\/code>: Rename and\/or move a file.<\/li>\n<li><code>git tag -a v1.0<\/code>: Tag a repository. Takes a snapshot of the repository (e.g. mark a release).<\/li>\n<li><code>git tag<\/code>: List all tags.<\/li>\n<li><code>git show v1.0<\/code>: Show information on a particular tag.<\/li>\n<li><code>git blame README.md<\/code>: Shows who committed which lines of code.<\/li>\n<li><code>git remote add branch URL<\/code>: Adds the remote branch named &#8220;branch&#8221; for the repository at URL.<\/li>\n<li><code>git push --set-upstream origin branch<\/code>: Push the current branch and set the remote as upstream.<\/li>\n<li><code>git diff<\/code>: Show changes between commits.<\/li>\n<\/ol>\n<h2 class=\"wp-block-heading\" id=\"h-14-git-tutorial-for-beginners-summary\"><a name=\"summary\"><\/a>14. Git Tutorial for Beginners Summary<\/h2>\n<p>There you have it. You have just performed the most common operations in Git. When you join a team, you will do a <code>git clone<\/code>. At the start of your working day, you do a pull to get the latest copy. You then make your changes, commit it and then push. This is the most common cycle you will be doing. It&#8217;s okay to commit partial work but push only working builds.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Git What? Welcome to the Git Tutorial for Beginners. What is Git? Git is a free and open source distributed version control system. It was originally developed by Linus Torvalds, the creator of the Linux operating system. Git is fast and can handle projects of different sizes. If you have a software project, chances &hellip;<\/p>\n","protected":false},"author":101,"featured_media":27377,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1353],"tags":[1203],"class_list":["post-59615","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-git","tag-git"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Git Tutorial for Beginners - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about Git? Then check out our detailed tutorial on Git Tutorial!You can also download our FREE Git Tutorial!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git Tutorial for Beginners - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about Git? Then check out our detailed tutorial on Git Tutorial!You can also download our FREE Git Tutorial!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-05T12:00:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-29T14:56:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Joel Patrick Llosa\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joel Patrick Llosa\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/\"},\"author\":{\"name\":\"Joel Patrick Llosa\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3fa3c5310d8b59b53457270ea3f9ce54\"},\"headline\":\"Git Tutorial for Beginners\",\"datePublished\":\"2018-09-05T12:00:51+00:00\",\"dateModified\":\"2022-07-29T14:56:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/\"},\"wordCount\":1340,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"keywords\":[\"git\"],\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/\",\"name\":\"Git Tutorial for Beginners - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"datePublished\":\"2018-09-05T12:00:51+00:00\",\"dateModified\":\"2022-07-29T14:56:16+00:00\",\"description\":\"Interested to learn more about Git? Then check out our detailed tutorial on Git Tutorial!You can also download our FREE Git Tutorial!\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Software Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Git\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/git\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Git Tutorial for Beginners\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3fa3c5310d8b59b53457270ea3f9ce54\",\"name\":\"Joel Patrick Llosa\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/10\/Joel-Llosa-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/10\/Joel-Llosa-96x96.jpg\",\"caption\":\"Joel Patrick Llosa\"},\"description\":\"I graduated from Silliman University in Dumaguete City with a degree in Bachelor of Science in Business Computer Application. I have contributed to many Java related projects at Neural Technologies Ltd., University of Southampton (iSolutions), Predictive Technologies, LLC., Confluence Service, North Concepts, Inc., NEC Telecom Software Philippines, Inc., and NEC Technologies Philippines, Inc. You can also find me in Upwork freelancing as a Java Developer.\",\"sameAs\":[\"https:\/\/jpllosa.blogspot.com\",\"https:\/\/www.linkedin.com\/in\/joel-patrick-llosa-b609aa183\/\",\"https:\/\/www.youtube.com\/channel\/UCXcCmh1sLiq2mjkJEO4FPyA\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/joel-llosa\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Git Tutorial for Beginners - Java Code Geeks","description":"Interested to learn more about Git? Then check out our detailed tutorial on Git Tutorial!You can also download our FREE Git Tutorial!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/","og_locale":"en_US","og_type":"article","og_title":"Git Tutorial for Beginners - Java Code Geeks","og_description":"Interested to learn more about Git? Then check out our detailed tutorial on Git Tutorial!You can also download our FREE Git Tutorial!","og_url":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-09-05T12:00:51+00:00","article_modified_time":"2022-07-29T14:56:16+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","type":"image\/jpeg"}],"author":"Joel Patrick Llosa","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Joel Patrick Llosa","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/"},"author":{"name":"Joel Patrick Llosa","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3fa3c5310d8b59b53457270ea3f9ce54"},"headline":"Git Tutorial for Beginners","datePublished":"2018-09-05T12:00:51+00:00","dateModified":"2022-07-29T14:56:16+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/"},"wordCount":1340,"commentCount":2,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","keywords":["git"],"articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/","url":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/","name":"Git Tutorial for Beginners - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","datePublished":"2018-09-05T12:00:51+00:00","dateModified":"2022-07-29T14:56:16+00:00","description":"Interested to learn more about Git? Then check out our detailed tutorial on Git Tutorial!You can also download our FREE Git Tutorial!","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/09\/git-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/git\/git-tutorial-for-beginners\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Software Development","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/"},{"@type":"ListItem","position":3,"name":"Git","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/git\/"},{"@type":"ListItem","position":4,"name":"Git Tutorial for Beginners"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3fa3c5310d8b59b53457270ea3f9ce54","name":"Joel Patrick Llosa","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/10\/Joel-Llosa-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/10\/Joel-Llosa-96x96.jpg","caption":"Joel Patrick Llosa"},"description":"I graduated from Silliman University in Dumaguete City with a degree in Bachelor of Science in Business Computer Application. I have contributed to many Java related projects at Neural Technologies Ltd., University of Southampton (iSolutions), Predictive Technologies, LLC., Confluence Service, North Concepts, Inc., NEC Telecom Software Philippines, Inc., and NEC Technologies Philippines, Inc. You can also find me in Upwork freelancing as a Java Developer.","sameAs":["https:\/\/jpllosa.blogspot.com","https:\/\/www.linkedin.com\/in\/joel-patrick-llosa-b609aa183\/","https:\/\/www.youtube.com\/channel\/UCXcCmh1sLiq2mjkJEO4FPyA"],"url":"https:\/\/examples.javacodegeeks.com\/author\/joel-llosa\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/59615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/101"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=59615"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/59615\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/27377"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=59615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=59615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=59615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}