{"id":805,"date":"2017-09-15T02:23:46","date_gmt":"2017-09-14T19:23:46","guid":{"rendered":"https:\/\/trichev.com\/blog\/?p=805"},"modified":"2017-09-15T02:23:46","modified_gmt":"2017-09-14T19:23:46","slug":"git-on-centos-6","status":"publish","type":"post","link":"https:\/\/trichev.com\/blog\/2017\/09\/15\/git-on-centos-6\/","title":{"rendered":"GIT on CentOS 6"},"content":{"rendered":"<p><strong>GIT + gitolite installation<\/strong><br \/>\nPrerequisites<br \/>\n<code>yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker<\/code><\/p>\n<p>GIT installation<br \/>\n<code>cd \/usr\/src<br \/>\nwget https:\/\/www.kernel.org\/pub\/software\/scm\/git\/git-2.2.0.tar.gz<br \/>\ntar zxvf git-2.2.0.tar.gz<br \/>\ncd git-2.2.0<\/code><\/p>\n<pre><code>make prefix=\/usr\/local\/git all\r\nmake prefix=\/usr\/local\/git install\r\necho \"export PATH=$PATH:\/usr\/local\/git\/bin\" &gt;&gt; \/etc\/bashrc\r\n#SLES\r\necho \"export PATH=$PATH:\/usr\/local\/git\/bin\" &gt;&gt; \/etc\/bash.bashrc<\/code><\/pre>\n<p><code>source \/etc\/bashrc<br \/>\n#SLES<br \/>\nsource \/etc\/bash.bashrc<\/code><\/p>\n<pre><code>#.bash_profile\r\n#export PATH=$PATH:\/usr\/local\/git\/bin<\/code><\/pre>\n<p><code>git --version<\/code><\/p>\n<p>After this is done, you can also get Git via Git itself for updates:<br \/>\n<code>cd \/usr\/src<br \/>\ngit clone git:\/\/git.kernel.org\/pub\/scm\/git\/git.git<br \/>\ncd git<\/code><\/p>\n<p><code>groupadd -g 54001 git<br \/>\nadduser -m --system -g git -d \/opt\/git -s \/bin\/bash git<\/code><\/p>\n<p><code>ssh-keygen -t rsa<br \/>\nscp .ssh\/id_rsa.pub root@192.168.1.84:\/tmp\/git-admin.pub<\/code><\/p>\n<p><code>su - git<br \/>\ngit clone git:\/\/github.com\/sitaramc\/gitolite<\/code><\/p>\n<p><code>cd $HOME<br \/>\nmkdir -p bin<br \/>\ngitolite\/install -to $HOME\/bin<\/code><\/p>\n<p><code>cd $HOME<br \/>\n$HOME\/bin\/gitolite setup -pk \/tmp\/git-admin.pub<\/code><\/p>\n<p><code>Now go to your workstation and type in<br \/>\ngit ls-remote git@server:gitolite-admin<\/code><\/p>\n<pre><code>This should return something like \r\n9dd8aab60bac5e54caf887a87b4f3d35c95b05e4    HEAD\r\n9dd8aab60bac5e54caf887a87b4f3d35c95b05e4    refs\/heads\/master<\/code><\/pre>\n<p><strong>GIT Configuration<\/strong><br \/>\nPrevent git push &#8211;force<br \/>\n<code>git config --system receive.denyNonFastForwards true<br \/>\ngit config --system receive.denyDeletes true<\/code><\/p>\n<pre><code>cat \/usr\/local\/git\/etc\/gitconfig\r\n[receive]\r\n       denyNonFastForwards = true\r\n       denyDeletes = true<\/code><\/pre>\n<p><strong>Administration from workstation<\/strong><br \/>\n<code>yum install git<br \/>\nmkdir \/home\/user\/work\/git<br \/>\ncd \/home\/user\/work\/git\/<br \/>\ngit clone git@srvgit01v:gitolite-admin<br \/>\ncd gitolite-admin\/<br \/>\nvim conf\/gitolite.conf<\/code><\/p>\n<p><code>git config --global user.name \"Git-Admin\"<br \/>\ngit config --global user.email \"user@domain.com\"<\/code><\/p>\n<p><code>git add keydir conf<br \/>\ngit commit -m 'added users, repos'<br \/>\ngit push origin master<\/code><\/p>\n<p><strong>Clients access<\/strong><\/p>\n<p>To check the available repos, and your access to them, use the following:<br \/>\n<code>ssh git@192.168.1.100 info<\/code><br \/>\nor<br \/>\n<code>ssh git@srvgit01v.sub1.domain.com info<\/code><\/p>\n<p>Clone down the repo using:<br \/>\n<code>git clone git@192.168.1.100:repo<\/code><br \/>\nor<br \/>\n<code>git clone git@srvgit01v.sub1.domain.com:repo<\/code><\/p>\n<p><strong>Mirroring gitolite servers<\/strong><br \/>\nGitolite: Add, Edit, or Delete Git Repository Name<\/p>\n<p>Add or create repository<br \/>\nAdd entry for new project or repository in your gitolite config (conf\/gitolite.conf)<br \/>\nCommit and push your changes. this will create and initialize your new repo.<\/p>\n<p>Rename a repository<br \/>\nModify the name of repo in your gitolite config (conf\/gitolite.conf)<br \/>\nMove or rename the actual directory (depending on where you install it, ex: \/home\/git\/repositories) to match your changes in gitolite config.<br \/>\nCommit and push your changes.<\/p>\n<p>Note: Obviously, this changes the remote url of your repo, so don\u2019t forget to change your git remote url config in your project clones.<\/p>\n<p>Delete a repository:<br \/>\nOpen your gitolite config and remove the project from there. commit and push your changes.<br \/>\nThen delete its git directory (ex: \/home\/git\/repositories\/projectname.git)<br \/>\nYou can also remove users\/keys that are no longer used<\/p>\n<p><strong>Generate GIT 2.2 RPM<\/strong><br \/>\n<code>yum install -y rpm-build<\/code><\/p>\n<p><code>mkdir -p ~\/rpmbuild\/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}<\/code><\/p>\n<p><code>mkdir -p ~\/src &amp;&amp; cd ~\/src<br \/>\nwget https:\/\/www.kernel.org\/pub\/software\/scm\/git\/git-2.2.0.tar.gz<br \/>\ntar -xzvf git-2.2.0.tar.gz<br \/>\nmv git-2.2.0.tar.gz ~\/rpmbuild\/SOURCES<\/code><\/p>\n<p># Locate .spec file and build rpm<br \/>\n# If you get any errors during build, it is usually because of dependencies. Simply<br \/>\n# install the dependencies with `yum install [dependency]` and run rpmbuild again.<\/p>\n<p><code>cd ~\/src\/git-2.2.0 &amp;&amp; ls | grep *.spec<\/code><\/p>\n<p><code>rpmbuild -ba git.spec --define '_prefix \/usr\/local'<\/code><\/p>\n<p>Find<\/p>\n<pre><code>%files -n perl-Git -f perl-files\r\n%defattr(-,root,root)<\/code><\/pre>\n<p>and add<br \/>\n#for CentOS 6<br \/>\n<code>%config(noreplace) \/usr\/local\/git\/share\/perl5\/vendor_perl\/*<\/code><\/p>\n<p>or<\/p>\n<p>#for CentOS 5<br \/>\n<code>%config(noreplace) \/usr\/local\/lib\/perl5\/vendor_perl\/5.8.8\/*<br \/>\n%config(noreplace) \/usr\/local\/share\/man\/man3\/*<\/code><\/p>\n<p>If error: File \/usr\/src\/redhat\/SOURCES\/git-2.2.0.tar.gz: No such file or directory<br \/>\n<code>echo '%_topdir %(echo $HOME)\/rpmbuild' &gt; ~\/.rpmmacros<\/code><\/p>\n<p>or<br \/>\n#for Centos 7<br \/>\nFind<\/p>\n<pre><code>%files -n perl-Git -f perl-files\r\n%defattr(-,root,root)<\/code><\/pre>\n<p>and add<\/p>\n<pre><code>%config(noreplace) \/usr\/local\/share\/perl5\/vendor_perl\/*<\/code><\/pre>\n<p><strong>Install GIT 2.2 RPM<\/strong><br \/>\n#CentOS 5<\/p>\n<p>Installation of RPMforge<br \/>\n<a href=\"http:\/\/wiki.centos.org\/AdditionalResources\/Repositories\/RPMForge#head-5aabf02717d5b6b12d47edbc5811404998926a1b\">RPMforge<\/a><br \/>\n<code>wget http:\/\/pkgs.repoforge.org\/rpmforge-release\/rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm<br \/>\nrpm --import http:\/\/apt.sw.be\/RPM-GPG-KEY.dag.txt<br \/>\nrpm -i rpmforge-release-0.5.3-1.el5.rf.*.rpm<br \/>\nyum install perl-YAML<\/code><\/p>\n<p>or<br \/>\n<code>wget http:\/\/pkgs.repoforge.org\/perl-YAML\/perl-YAML-0.72-1.el5.rf.noarch.rpm<br \/>\nrpm --import http:\/\/apt.sw.be\/RPM-GPG-KEY.dag.txt<br \/>\nyum install perl-YAML-0.72-1.el5.rf.noarch.rpm <\/code><\/p>\n<p><code>yum install git-2.2.0-1.x86_64.rpm git-cvs-2.2.0-1.x86_64.rpm gitk-2.2.0-1.x86_64.rpm perl-Git-2.2.0-1.x86_64.rpm git-email-2.2.0-1.x86_64.rpm git-svn-2.2.0-1.x86_64.rpm git-gui-2.2.0-1.x86_64.rpm gitweb-2.2.0-1.x86_64.rpm --nogpgcheck<\/code><\/p>\n<p>#CentOS 6<\/p>\n<p><code>yum install git-2.2.0-1.el6.x86_64.rpm gitk-2.2.0-1.el6.x86_64.rpm git-cvs-2.2.0-1.el6.x86_64.rpm git-svn-2.2.0-1.el6.x86_64.rpm git-email-2.2.0-1.el6.x86_64.rpm gitweb-2.2.0-1.el6.x86_64.rpm git-gui-2.2.0-1.el6.x86_64.rpm perl-Git-2.2.0-1.el6.x86_64.rpm<\/code><\/p>\n<p>#CentOS 7<\/p>\n<p><code>yum install git-2.2.0-1.el7.centos.x86_64.rpm git-svn-2.2.0-1.el7.centos.x86_64.rpm git-cvs-2.2.0-1.el7.centos.x86_64.rpm git-email-2.2.0-1.el7.centos.x86_64.rpm git-gui-2.2.0-1.el7.centos.x86_64.rpm gitk-2.2.0-1.el7.centos.x86_64.rpm gitweb-2.2.0-1.el7.centos.x86_64.rpm perl-Git-2.2.0-1.el7.centos.x86_64.rpm git-debuginfo-2.2.0-1.el7.centos.x86_64.rpm<\/code><\/p>\n<p><strong>Delete Git branch<\/strong><br \/>\n<code>ssh root@srvgit01v<br \/>\ncd \/opt\/git\/repositories\/repo1.git<\/code><\/p>\n<p><code>git branch -D 4.1.0.6-rel<\/code><\/p>\n<p><code>chown -R git:git \/opt\/git\/repositories\/repo1.git<\/code><\/p>\n<p>Link:<br \/>\n<a href=\"http:\/\/www.tikalk.com\/devops\/backing-git-repos-git-bundle\/\">http:\/\/www.tikalk.com\/devops\/backing-git-repos-git-bundle\/<\/a><br \/>\n<a href=\"http:\/\/gitolite.com\/gitolite\/mirroring\/#setting-up-mirroring\">http:\/\/gitolite.com\/gitolite\/mirroring\/#setting-up-mirroring<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>GIT + gitolite installation Prerequisites yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker GIT installation cd \/usr\/src wget https:\/\/www.kernel.org\/pub\/software\/scm\/git\/git-2.2.0.tar.gz tar zxvf git-2.2.0.tar.gz cd git-2.2.0 make prefix=\/usr\/local\/git all make prefix=\/usr\/local\/git install echo &#8220;export PATH=$PATH:\/usr\/local\/git\/bin&#8221; &gt;&gt; \/etc\/bashrc #SLES echo &#8220;export PATH=$PATH:\/usr\/local\/git\/bin&#8221; &gt;&gt; \/etc\/bash.bashrc source \/etc\/bashrc #SLES source \/etc\/bash.bashrc #.bash_profile #export PATH=$PATH:\/usr\/local\/git\/bin git &#8211;version After this is [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[231],"tags":[247,248,32,14,11],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/805"}],"collection":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/comments?post=805"}],"version-history":[{"count":1,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/805\/revisions"}],"predecessor-version":[{"id":806,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/805\/revisions\/806"}],"wp:attachment":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/media?parent=805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/categories?post=805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/tags?post=805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}