🌱 Git Commands

Git Reference

How to create source from BARE:master (FILE.git)

cd PARENT/DIR
git clone PATH/TO/FILE.git

Setup push to server

http://toroid.org/ams/git-website-howto

Set up bare repository

  1. SSH into server
  2. mkdir REPO-NAME.git && cd REPO-NAME.git
  3. git init --bare
  4. Add the following to hooks/post-receive
#!/bin/sh
while read oldrev newrev ref
do
    branch=`echo $ref | cut -d/ -f3`
    GIT_WORK_TREE=/opt/sites/kiosk.makersmark.com/html/ git checkout -f $branch
done
  1. chmod +x hooks/post-receive

Add remote to local repo

  1. git remote add NAME ssh://serveraddress/path/to/REPO-NAME.git
  2. git push NAME +master:refs/heads/master

Pushing

git push NAME BRANCH

Add branch syntax

http://blog.ekynoxe.com/2011/10/22/git-post-receive-for-multiple-remote-branches-and-work-trees/

#!/bin/bash

while read oldrev newrev ref
do
  branch=`echo $ref | cut -d/ -f3`

  if [ "master" == "$branch" ]; then
    git --work-tree=/path/under/root/dir/live-site/ checkout -f $branch
    echo 'Changes pushed live.'
  fi

  if [ "dev" == "$branch" ]; then
    git --work-tree=/path/under/root/dir/dev-site/ checkout -f $branch
    echo 'Changes pushed to dev.'
  fi
done

Modified for my stuff

#!/bin/sh
while read oldrev newrev ref
do
    branch=`echo $ref | cut -d/ -f3`
    GIT_WORK_TREE=/var/www/vhosts/red-stash.com/SITE_NAME/ git checkout -f $branch
done

Remove stuff from git

http://gitready.com/beginner/2009/01/19/ignoring-files.html

git rm --cached <file>

Make new branch from old state

git checkout -b old-state 0d1d7fc32

Legacy bare init

git --bare init

Case change a file

git mv -f OldFileNameCase newfilenamecase
Made by Brandon . If you find this project useful you can donate.