Circle Device


Quick Reference

git Workflow

git Workflow

To begin with I have two branches, master and development. The master branch is the one where the working code lives that which is deployed to the customer or deployed on your production servers, I am sure you can guess what development is for.

Setting up your project

First the server side. On my server I do this in /home/git and to make sure I the repository is shared properly with developers I need to perform the repo creation as ben (the repo owner) if I run this as root or git the repo will inherit that users permissions and that is likely not what we want.

mkdir dht.git
chown ben:developers dht.git
cd dht.git
su ben
git init --bare --shared .

Now you have a repo on the server, next create the repo on your local machine.

cd dht
git init .
git add .
git commit -m "Initial commit"
git branch -m master development
git remote add origin ssh://ben@
git push origin development

Here we created the repo, added files, committed the changes with a comment "Initial commit", renamed the default branch from master to development added the server repo and pushed the branch development to the server.

Using this repo and the development branch

So you have a repo with a master branch and a development branch on your server. To get the development branch on the new client:

git clone git://ben@
git checkout development

If you made the development branch after you cloned the repo, you will need to do a git fetch so that you can see the branch

Although not for everyone I seem to find this works well for me.

First Release

When you release your code you will want to merge your changes to the master branch, the first time you do this (if you followed the instructions above) will be a little like this (I am assuming you have committed your work and the directory is "clean"):

git branch master
git checkout master

As we renamed the branch earlier we have now created a new branch called master. You may also do this in a shorthand: git checkout -b master that will create a branch and switch to it. Now we have our new branch we are done because the master and development branch point to the same commit.

Next Release

Now we have made some changes in development and want to deploy them to the world! (all our tests are passing and we are ready to go). Switch to the master branch and merge the development branch.

git checkout master
git merge development

This is all crap, read this

Killing Local Branches that WERE on Remote

This quick command will use the output of git branch -vv looking for : gone] and removing it.

$ git branch -vv
  master                 b900de9 [origin/master: behind 4] Fixed bug
  release/v3.8           fdd2f4e [origin/release/v3.8: behind 2] Fixed bug
  release/v3.9           0d680d0 [origin/release/v3.9: behind 2] Updated comments
  bug/1234               57379e4 [origin/bug/1234: gone] Fixed bug
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
SO Question

Revert Commits already pushed...

Naughty! How to do it

Quick Links: Techie Stuff | General | Personal | Quick Reference