{"id":3117,"date":"2012-11-15T13:34:12","date_gmt":"2012-11-15T11:34:12","guid":{"rendered":"http:\/\/skeletor.org.ua\/?p=3117"},"modified":"2016-11-10T13:39:46","modified_gmt":"2016-11-10T11:39:46","slug":"%d0%bd%d0%b5%d0%b1%d0%be%d0%bb%d1%8c%d1%88%d0%be%d0%b9-tutorial-%d0%b4%d0%bb%d1%8f-%d1%80%d0%b0%d0%b1%d0%be%d1%82%d1%8b-%d1%81-git%d0%be%d0%bc","status":"publish","type":"post","link":"https:\/\/skeletor.org.ua\/?p=3117","title":{"rendered":"\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 tutorial \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 git&#8217;\u043e\u043c (\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 gitosis)"},"content":{"rendered":"<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0443 \u0432\u0430\u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d <strong>gitosis<\/strong>, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u0435\u0433\u043e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0438\u0436\u0435 \u043e\u043f\u0438\u0448\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/p>\n<p><!--more--><\/p>\n<p><strong><span style=\"color: #ff0000;\">1) \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u0430<\/span><\/strong><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043b\u043e\u043d \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u0430\u0440\u0438\u044f gitosis-admin.git:<\/span><\/em><\/p>\n<p><code>$git clone ssh:\/\/git@gitosis\/gitosis-admin.git<\/code><\/p>\n<p>\u0433\u0434\u0435 <strong>gitosis<\/strong> &#8211; \u0430\u043b\u0438\u0430\u0441 \u0445\u043e\u0441\u0442\u0430, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432 <strong>~\/.ssh\/config<\/strong><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u0430\u0440\u0438\u0439 \u0438 \u043f\u0440\u0430\u0432\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433<\/span><\/em><\/p>\n<p><code>$cd gitosis-admin &amp;&amp; nano gitosis.conf<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u044e\u0437\u0435\u0440\u0430 USER<\/span><\/em> (\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 <strong>gitosis<\/strong> \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u044e\u0437\u0435\u0440\u0430 <strong>git<\/strong> \u043d\u043e \u043f\u043e \u043a\u043b\u044e\u0447\u0430\u043c; \u043a\u0430\u0436\u0434\u044b\u0439 \u044e\u0437\u0435\u0440 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0430\u0440\u0443 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0441\u044b\u043b\u0430\u0435\u0442 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443)<\/p>\n<p><code>$git add keydir\/USER.pub<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0434\u0435\u043b\u0430\u0435\u043c commit<\/span><\/em> (\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0438\u043d\u0430\u0447\u0435 <strong>git diff<\/strong> \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0432\u0435\u0434\u0435\u0442)<\/p>\n<p><code>$git commit -a -m \"Added user USER to the git project\"<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/span><\/em><\/p>\n<p><code>$git diff origin\/master..HEAD<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0434\u0435\u043b\u0430\u0435\u043c push<\/span><\/em><\/p>\n<p><code>$git push<\/code><\/p>\n<p><strong><span style=\"color: #ff0000;\">2) \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u0430\u0440\u0438\u044f.<\/span><\/strong><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 gitosis \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u043f\u043a\u0443<\/span><\/em> (\u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u044e\u0437\u0435\u0440\u0430 <strong>git<\/strong>)<\/p>\n<p><code>$cd ~\/repositories &amp;&amp; mkdir someproject.git &amp;&amp; cd someproject.git\/<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/span><\/em><\/p>\n<p><code>$git init --bare<br \/>\n&gt;&gt; Initialized empty Git repository in \/home\/git\/repositories\/someproject.git\/<\/code><\/p>\n<p>\u0427\u0442\u043e \u0431\u044b \u0434\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u044e\u0437\u0435\u0440\u0443 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u0430\u0440\u0438\u0439 &#8211; \u0434\u0435\u043b\u0430\u0435\u043c \u043a\u0430\u043a \u0432 \u043f1 (\u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c <strong>gitosis.conf<\/strong>, \u0434\u0435\u043b\u0430\u0435\u043c <strong>commit<\/strong> \u0438 <strong>push<\/strong>)<\/p>\n<p><strong><span style=\"color: #ff0000;\">3) \u041a\u0440\u0430\u0442\u043a\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/span><\/strong><\/p>\n<p>\u041f\u0440\u0438\u044f\u0442\u043d\u043e\u0439 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u0435\u0441\u0442\u044c \u0442\u043e, \u0447\u0442\u043e <strong>git<\/strong> \u043f\u0438\u0448\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0432 <strong>~\/history.git<\/strong>.<\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0443\u0437\u043d\u0430\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c \u0431\u0440\u0430\u043d\u0447\u0435 \u0438 \u043a\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c:<\/span><\/em><\/p>\n<p><code>$ git status<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043d\u0430 \u0431\u0440\u0430\u043d\u0447:<\/span><\/em><\/p>\n<p><code>$ git chekout \u0418\u041c\u042f_\u0411\u0420\u0410\u041d\u0427\u0410<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0441\u043b\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0440\u0430\u043d\u0447\u0430:<\/span><\/em><\/p>\n<p><code>$ git pull origin\u00a0\u0418\u041c\u042f_\u0411\u0420\u0410\u041d\u0427\u0410<\/code><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u043b\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0432\u0435\u0442\u043a\u0438, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0430\u0442\u043a\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443<\/p>\n<p><code>$ git pull<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u0441\u0435\u0445 \u043f\u0440\u0430\u0432\u043e\u043a \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e:<\/span><\/em><\/p>\n<p><code>$ git reset --hard<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0431\u0440\u0430\u043d\u0447<\/span><\/em> (\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0431\u0440\u0430\u043d\u0447, \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043d\u0435\u0433\u043e, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043b\u0438 \u043e\u043d \u0442\u0430\u043c)<\/p>\n<p><code>$ git branch NEW_BRANCH<br \/>\n$ git checkout NEW_BRANCH<br \/>\n$ git push origin\u00a0NEW_BRANCH<br \/>\n$\u00a0git branch -r | grep\u00a0NEW_BRANCH<\/code><\/p>\n<p>\u041d\u043e \u043b\u0443\u0447\u0448\u0435 \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043d\u0435 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0432 \u043c\u0430\u0441\u0442\u0435\u0440\u0435:<\/p>\n<p><code>$\u00a0git pull origin\u00a0branch22<br \/>\n$\u00a0git push origin\u00a0branch22<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0446\u0432\u0435\u0442\u043e\u0432\u0443\u044e \u0441\u0445\u0435\u043c\u0443<\/span><\/em><\/p>\n<p><code>$ git config --global color.ui true<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<\/span><\/em><\/p>\n<p><code>$\u00a0git log -p unix\/nginx\/vhost_templates\/vhost.conf.tpl<\/code><\/p>\n<p><em><span style=\"color: #ff6600;\">&#8211; \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u0430:<\/span><\/em><\/p>\n<p><code>$ git log -p --committer=skeletor<\/code><\/p>\n<p>\u0420\u0430\u0437\u043d\u043e\u0435.<\/p>\n<ul>\n<li><a href=\"https:\/\/habrahabr.ru\/post\/313890\/\">git \u0438\u0437\u043d\u0443\u0442\u0440\u0438<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0443 \u0432\u0430\u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d gitosis, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u0435\u0433\u043e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0438\u0436\u0435 \u043e\u043f\u0438\u0448\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-3117","post","type-post","status-publish","format-standard","hentry","category-others"],"_links":{"self":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/3117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3117"}],"version-history":[{"count":11,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/3117\/revisions"}],"predecessor-version":[{"id":5077,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/3117\/revisions\/5077"}],"wp:attachment":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}