Difference between revisions of "Git"

From KeegansWiki
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
=New Clone=
+
=Simple Git Stuff=
* service puppet stop; service puppetmaster stop; rm -fr /etc/puppet; http_proxy=proxy.traderonline.com:80 git clone http://git.dhsint.com/puppetconf-tol.git /etc/puppet; cd /etc/puppet; git config --global http.proxy proxy.traderonline.com:80; service puppet start
+
==Make edits==
* cd /etc/puppet; git submodule init; git submodule update
+
git clone git@git01.phpfog.com:removed.phpfogapp.com
 +
git checkout -b firstedit
 +
vi index.php
 +
git commit -a -m "First edit"
 +
git checkout master
 +
git merge firstedit
 +
git push
  
=Creating a new Branch=
+
 
 +
=View previously merged branches=
 +
First, run this:
 +
* git log --oneline --first-parent
 +
Locate the identifier of the desired branch, and the previous one, for example:
 +
961e4f9 Merge remote-tracking branch 'tol/mysql'                                                                                                                                               
 +
3cb72fb Merge remote-tracking branch 'tol/nfs-requires-rstatd'
 +
So for the mysql branch, run this:
 +
*git log --patch --reverse  3cb72fb..961e4f9
 +
 
 +
=Setting up a new DHS repo based on a TOL repo=
 
* on dssysdev02
 
* on dssysdev02
** git clone --bare http://git.ops.traderonline.com/centos-netinstall-dws.git /path/to/centos-netinstall-dws.git
+
REPONAME=centos-netinstall-dws.git
** cd /path/to/centos-netinstall-dws.git
+
git clone --bare http://git.ops.traderonline.com/${REPONAME} /path/to/${REPONAME}
** git remote rm origin
+
cd /path/to/${REPONAME}
** cd /path/to/centos-netinstall-dws.git; git update-server-info; mv hooks/post-update.sample hooks/post-update
+
git remote rm origin #dont do this if editing from git
 +
git update-server-info
 +
mv hooks/post-update.sample hooks/post-update
 
* on laptop
 
* on laptop
** git clone ssh://root@git.dhsint.com/path/to/centos-netinstall-dws.git
+
REPONAME=centos-netinstall-dws.git
** git checkout -b set-default-options
+
git clone ssh://root@git.dhsint.com/path/to/${REPONAME}
=Pushing new branch after edits=
+
 
* git add <edited file>
+
=Making changes to files=
* git commit  
+
git checkout master
* git push origin set-default-options:set-default-options
+
BRANCHNAME=set-default-options
 +
git checkout -b ${BRANCHNAME}
 +
# Make changes
 +
git add <edited file(s)>
 +
git commit  
 +
git push origin ${BRANCHNAME}:${BRANCHNAME}
 +
 
 
=Overwriting updates to a branch=
 
=Overwriting updates to a branch=
* git add <edited file>
+
BRANCHNAME=set-default-options
* git commit --ammend
+
git add <edited file>
* git push origin +set-default-options:set-default-options
+
git commit --amend
 +
git push origin +${BRANCHNAME}:${BRANCHNAME}
 +
 
 
=Merge My Edits=
 
=Merge My Edits=
* git checkout master
+
BRANCHNAME=set-default-options
* git merge --no-ff set-default-options
+
git checkout master
* git push origin master:master
+
git merge --no-ff ${BRANCHNAME}
 +
git push origin master:master
 +
# Once that is complete, delete the branch
 +
git push origin :${BRANCHNAME}  #only do if someone else needs to review
 +
git branch -d ${BRANCHNAME}
 +
 
 +
=Merging Someone Else's Edits=
 +
REMOTENAME=tol
 +
BRANCHNAME=set-default-options
 +
git checkout master
 +
git rev-parse HEAD
 +
git merge-base HEAD ${REMOTENAME}/${BRANCHNAME}
 +
git merge --no-ff ${REMOTENAME}/${BRANCHNAME}
 +
git push origin master:master
  
Once that is complete, delete the branch
+
=TOL Specifics=
* git push origin :set-default-options
+
==Adding a new role==
* git branch -d set-default-options
+
* puppetconf-tol/modules/tol/manifests/init.pp
 +
if $role == "image-server" {
 +
    class { "nginx":
 +
    }
 +
 +
    iptables { "100 allow nginx":
 +
      proto => "tcp",
 +
      dport => "80",
 +
      jump  => "ACCEPT",
 +
    }
 +
  }
  
=Merging Someone Else's Edits=
+
* puppetconf-tol/manifests/nodes.pp
* git rev-parse HEAD
+
node /img/ {
* git merge-base HEAD tol/<branch>
+
  class { "tol":
* git merge --no-ff tol/<branch>
+
    role => "image-server",
* git push origin master:master
+
  }
 +
}

Latest revision as of 08:10, 31 January 2012

Simple Git Stuff

Make edits

git clone git@git01.phpfog.com:removed.phpfogapp.com
git checkout -b firstedit
vi index.php
git commit -a -m "First edit"
git checkout master
git merge firstedit
git push


View previously merged branches

First, run this:

  • git log --oneline --first-parent

Locate the identifier of the desired branch, and the previous one, for example:

961e4f9 Merge remote-tracking branch 'tol/mysql'                                                                                                                                                 
3cb72fb Merge remote-tracking branch 'tol/nfs-requires-rstatd'

So for the mysql branch, run this:

  • git log --patch --reverse 3cb72fb..961e4f9

Setting up a new DHS repo based on a TOL repo

  • on dssysdev02
REPONAME=centos-netinstall-dws.git
git clone --bare http://git.ops.traderonline.com/${REPONAME} /path/to/${REPONAME}
cd /path/to/${REPONAME}
git remote rm origin #dont do this if editing from git
git update-server-info
mv hooks/post-update.sample hooks/post-update
  • on laptop
REPONAME=centos-netinstall-dws.git
git clone ssh://root@git.dhsint.com/path/to/${REPONAME}

Making changes to files

git checkout master
BRANCHNAME=set-default-options
git checkout -b ${BRANCHNAME}
# Make changes
git add <edited file(s)>
git commit 
git push origin ${BRANCHNAME}:${BRANCHNAME}

Overwriting updates to a branch

BRANCHNAME=set-default-options
git add <edited file>
git commit --amend
git push origin +${BRANCHNAME}:${BRANCHNAME}

Merge My Edits

BRANCHNAME=set-default-options
git checkout master
git merge --no-ff ${BRANCHNAME}
git push origin master:master
# Once that is complete, delete the branch
git push origin :${BRANCHNAME}  #only do if someone else needs to review
git branch -d ${BRANCHNAME}

Merging Someone Else's Edits

REMOTENAME=tol
BRANCHNAME=set-default-options
git checkout master
git rev-parse HEAD
git merge-base HEAD ${REMOTENAME}/${BRANCHNAME}
git merge --no-ff ${REMOTENAME}/${BRANCHNAME}
git push origin master:master

TOL Specifics

Adding a new role

  • puppetconf-tol/modules/tol/manifests/init.pp
if $role == "image-server" {
   class { "nginx":
   }

   iptables { "100 allow nginx":
     proto => "tcp",
     dport => "80",
     jump  => "ACCEPT",
   }
 }
  • puppetconf-tol/manifests/nodes.pp
node /img/ {
 class { "tol":
   role => "image-server",
 }
}