{"id":3092,"date":"2023-11-21T12:10:14","date_gmt":"2023-11-21T11:10:14","guid":{"rendered":"https:\/\/www.saskialund.de\/?p=3092"},"modified":"2024-08-18T19:26:53","modified_gmt":"2024-08-18T17:26:53","slug":"master-git-and-ssh-a-guide-to-becoming-a-professional-in-code-management","status":"publish","type":"post","link":"https:\/\/isla-stud.io\/en\/howtos-anleitungen\/meistern-sie-git-und-ssh-ein-leitfaden-auf-dem-weg-zum-profi-im-code-management\/","title":{"rendered":"Master Git and SSH: A guide to becoming a code management pro"},"content":{"rendered":"<p>Welcome to this tutorial, in which we will look at versioning and teamwork in software development. You will learn how to set up a private Git repository and synchronize it with a target SSH directory. This setup is ideal for developing WordPress plugins, themes or other code components where a detailed edit history and team collaboration are crucial.<\/p>\n\n\n\n<div class=\"wp-block-columns blindhelper is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\t\t\t<div id=\"rank-math-rich-snippet-wrapper\" class=\"\">\n\n\t\t\t\t\t\t<h5 class=\"rank-math-title\"> <\/h5>\n\t\t\t\t<div class=\"rank-math-review-image\">\n\t\t\t<img decoding=\"async\" src=\"https:\/\/isla-stud.io\/wp-content\/uploads\/2023\/11\/git-ssh-repo-leitfaden_blog-300x200.jpg\" alt=\"\" data-no-translation=\"\" data-no-auto-translation=\"\">\n\t\t<\/div>\n\t\t<div class=\"rank-math-review-data\">\n\n\t\t\t<p><\/p>\n\t\t\n\t\t\t<p>\n\t\t\t<strong>Course Provider: <\/strong>\n\t\t\tPerson\t\t<\/p>\n\t\t\n\t\t\t<p>\n\t\t\t<strong>Course Provider Name: <\/strong>\n\t\t\tSaskia Teichmann\t\t<\/p>\n\t\t\n\t\t\t<p>\n\t\t\t<strong>Course Provider URL: <\/strong>\n\t\t\thttps:\/\/www.saskialund.de\/\t\t<\/p>\n\t\t\n\t\t\t<p>\n\t\t\t<strong>Course Mode: <\/strong>\n\t\t\tOnline\t\t<\/p>\n\t\t\n\t\t\t<p>\n\t\t\t<strong>Course Workload: <\/strong>\n\t\t\tPT30M\t\t<\/p>\n\t\t\n\t\n\t\n\t\n\t\n\t\n\t\t\t<p>\n\t\t\t<strong>Course Type: <\/strong>\n\t\t\tFree\t\t<\/p>\n\t\t\n\t\n\t\n\t\n<\/div>\n\n\t\t\t<\/div>\n\t\t\n<\/div>\n<\/div>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #2c292e;color:#2c292e\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\" data-no-auto-translation=\"\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #2c292e;color:#2c292e\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\" data-no-auto-translation=\"\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/isla-stud.io\/en\/howtos-anleitungen\/meistern-sie-git-und-ssh-ein-leitfaden-auf-dem-weg-zum-profi-im-code-management\/#Vorbereitungen_fur_diesen_Leitfaden\" >Preparations for this guide<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/isla-stud.io\/en\/howtos-anleitungen\/meistern-sie-git-und-ssh-ein-leitfaden-auf-dem-weg-zum-profi-im-code-management\/#Einrichten_eines_privaten_lokalen_Git-Repositories\" >Setting up a private, local Git repository<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/isla-stud.io\/en\/howtos-anleitungen\/meistern-sie-git-und-ssh-ein-leitfaden-auf-dem-weg-zum-profi-im-code-management\/#Synchronisieren_des_Git-Repositories_mit_einem_SSH-Zielverzeichnis\" >Synchronizing the Git repository with an SSH target directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/isla-stud.io\/en\/howtos-anleitungen\/meistern-sie-git-und-ssh-ein-leitfaden-auf-dem-weg-zum-profi-im-code-management\/#Arbeiten_mit_GitHub\" >Working with GitHub<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/isla-stud.io\/en\/howtos-anleitungen\/meistern-sie-git-und-ssh-ein-leitfaden-auf-dem-weg-zum-profi-im-code-management\/#Automatisches_Pushen_von_Releases_Veroffentlichungen_auf_das_SSH-Ziel\" >Automatic pushing of releases (publications) to the SSH target<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/isla-stud.io\/en\/howtos-anleitungen\/meistern-sie-git-und-ssh-ein-leitfaden-auf-dem-weg-zum-profi-im-code-management\/#Anderungen_vom_SSH-Ziel_in_das_lokale_Repository_ziehen\" >Drag changes from the SSH target to the local repository<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/isla-stud.io\/en\/howtos-anleitungen\/meistern-sie-git-und-ssh-ein-leitfaden-auf-dem-weg-zum-profi-im-code-management\/#Anderungen_vom_GitHub_Remote_Repository_ins_lokale_Repository_ubernehmen\" >Apply changes from the GitHub remote repository to the local repository<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/isla-stud.io\/en\/howtos-anleitungen\/meistern-sie-git-und-ssh-ein-leitfaden-auf-dem-weg-zum-profi-im-code-management\/#Fazit_Gemeinsam_wachsen_durch_Teilen_und_Lernen\" >Conclusion: Growing together through sharing and learning<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Vorbereitungen_fur_diesen_Leitfaden\"><\/span>Preparations for this guide<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Before you start, make sure that your local setup meets the following requirements:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Git installed<\/strong>Check whether Git is installed on your system and on the desired remote server. If not, you can download it from <a href=\"https:\/\/git-scm.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">git-scm.com<\/a> download and install.<\/li>\n\n\n\n<li><strong>SSH access<\/strong>Make sure that you have SSH access to the server you want to work with.<\/li>\n\n\n\n<li><strong>Text editor<\/strong>A basic text editor such as Nano, Vim or a similar program should be installed.<\/li>\n\n\n\n<li><strong>Internet connection<\/strong>A stable Internet connection is required to interact with remote repositories.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Einrichten_eines_privaten_lokalen_Git-Repositories\"><\/span>Setting up a private, local Git repository<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First, set up your own private Git repository. This repository serves as a central point of contact where all versions of your code are stored.<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code lang=\"bash\" class=\"language-bash\">git init MyProject # Initializes a new Git repository named 'MyProject'\ncd MyProject # Changes to the directory just created\ngit add .             # Adds all current files to the repository\ngit commit -m \"First commit\" # Creates a 'commit' with the message 'First commit'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Synchronisieren_des_Git-Repositories_mit_einem_SSH-Zielverzeichnis\"><\/span>Synchronizing the Git repository with an SSH target directory<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here you synchronize your local Git repository with a remote directory via SSH. This allows you to securely store your work on a remote server and share it with team members.<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code lang=\"bash\" class=\"language-bash\">ssh root@ihr-server.com \"mkdir \/path\/to\/target-directory\" # Creates a directory on the server\nssh root@ihr-server.com \"cd \/path\/to\/target-directory; git init --bare\" # Initializes a 'bare' Git repository on the server\ngit remote add origin ssh:\/\/root@ihr-server.com\/pfad\/zum\/zielverzeichnis # Links your local repository with the remote repository. The remote repository is now managed under the identifier \"origin\". You can also use a different identifier.\ngit push origin master # Sends your local changes to the remote repository<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Arbeiten_mit_GitHub\"><\/span>Working with GitHub<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you prefer to work with GitHub or would like to connect an additional remote repository, you can also connect your local repository to a GitHub repository:<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code lang=\"bash\" class=\"language-bash\">ssh root@ihr-server.com \"mkdir \/path\/to\/target-directory\" # Creates a directory on the server\nssh root@ihr-server.com \"cd \/path\/to\/target-directory; git init --bare\" # Initializes a 'bare' Git repository on the server\ngit remote add origin ssh:\/\/root@ihr-server.com\/pfad\/zum\/zielverzeichnis # Links your local repository with the remote repository\ngit push origin master # Sends your local changes to the remote repository<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Automatisches_Pushen_von_Releases_Veroffentlichungen_auf_das_SSH-Ziel\"><\/span>Automatic pushing of releases (publications) to the SSH target<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Automate the deployment of your changes to the server with a post-receive hook:<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code lang=\"bash\" class=\"language-bash\">ssh root@ihr-server.com # Connects to the server\ncd \/path\/to\/target-directory # Changes to the target directory\nnano hooks\/post-receive # Creates or edits the 'post-receive' hook script<\/code><\/pre>\n\n\n\n<p>Insert the following script to automatically apply changes to the working directory on the server:<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code lang=\"bash\" class=\"language-bash\">#!\/bin\/sh\nGIT_WORK_TREE=\/path\/to\/working-directory git checkout -f # Updates the working directory on the server with the latest changes\nchown -R username:groupname \/path\/to\/workingdirectory # Changes the owner of the files in the working directory\nchmod +x hooks\/post-receive # Makes the script executable\nOptional:\nchown -R 33:33 \/path\/to\/working-directory # Ensures that the files and directories in the working directory are assigned to a specific server user and server user group. I use 33:33 here because these are the IDs of my web server user and the web server user group www-data.<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Anderungen_vom_SSH-Ziel_in_das_lokale_Repository_ziehen\"><\/span>Drag changes from the SSH target to the local repository<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Transfer changes made on the SSH target server to your local repository:<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code lang=\"bash\" class=\"language-bash\">ssh root@ihr-server.com # Connects to the server\ncd \/path\/to\/working-directory # Changes to the working directory on the server\ngit add .  # Adds all new or changed files to the commit\ngit commit -m \"Description of changes\" # Creates a new commit with your change description\ngit push origin master # Sends the changes to the remote repository\ngit pull origin master # Pulls the latest changes from the remote repository to your local repository<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Anderungen_vom_GitHub_Remote_Repository_ins_lokale_Repository_ubernehmen\"><\/span>Apply changes from the GitHub remote repository to the local repository<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Finally, you will learn how to efficiently integrate changes made in the GitHub remote repository into the local repository. This is particularly useful if you work in a team where several people are working on different parts of a project at the same time, such as when developing complex software or collaboratively creating a WordPress theme or plugin. By regularly updating your local repository, you ensure that you are always up to date with the latest collaborative work.<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code lang=\"bash\" class=\"language-bash\">git fetch origin master # Fetches the latest information from the GitHub repository\ngit merge origin\/master # Merges the changes from the GitHub repository into your local repository<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Fazit_Gemeinsam_wachsen_durch_Teilen_und_Lernen\"><\/span>Conclusion: Growing together through sharing and learning<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We have now reached the end of this guide, and I hope you find these insights into using Git and SSH useful. Remember that mastering these tools will not only improve your individual software development skills, but also pave the way for more efficient and harmonious team projects.<\/p>\n\n\n\n<p>I invite you to share your thoughts, experiences or questions in the comments. Have you had any experience with Git and SSH? Are there any particular challenges you've encountered or tips you'd like to share with the community? Your feedback is not only valuable to me, but also to other readers.<\/p>\n\n\n\n<p>Your contribution could be the key that helps someone else solve a problem or discover a new perspective. I look forward to hearing from you!<\/p>\n\n\n\n<p>Until next time, stay curious and get involved in the world of coding! \ud83c\udf1f\ud83d\udc68\u200d\ud83d\udcbb\ud83d\udc69\u200d\ud83d\udcbb<\/p>","protected":false},"excerpt":{"rendered":"<p>Discover the world of Git and SSH! Learn how to create your own Git repository, synchronize with an SSH server and work effectively in a team.<\/p>","protected":false},"author":1,"featured_media":3101,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_et_pb_use_builder":"off","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[19,13,20],"tags":[657,658,659,660],"dipi_cpt_category":[],"class_list":["post-3092","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos-anleitungen","category-ratgeber","category-tipps-tricks","tag-git","tag-github","tag-ssh","tag-wordpress-entwicklung"],"acf":[],"_links":{"self":[{"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/posts\/3092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/comments?post=3092"}],"version-history":[{"count":11,"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/posts\/3092\/revisions"}],"predecessor-version":[{"id":3255,"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/posts\/3092\/revisions\/3255"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/media\/3101"}],"wp:attachment":[{"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/media?parent=3092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/categories?post=3092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/tags?post=3092"},{"taxonomy":"dipi_cpt_category","embeddable":true,"href":"https:\/\/isla-stud.io\/en\/wp-json\/wp\/v2\/dipi_cpt_category?post=3092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}